正则表达式仅捕获符号

时间:2018-12-10 20:16:46

标签: google-bigquery

任何人都知道适当的正则表达式来获取任何符号(例如。/ _等)。我正在尝试提取所有看起来不像1-3个完整单词的东西。

Online Chat
http://mailserver.test.com/zjalLNG391Vkfalka0
social
test.com
poc_email_outbound~51-tester-test~2018-04-12
http://mailserver.test.com/u/130931jiojf101901

仅抓取以下内容:

http://mailserver.test.com/zjalLNG391Vkfalka0
test.com
poc_email_outbound~51-tester-test~2018-04-12
http://mailserver.test.com/u/130931jiojf101901

1 个答案:

答案 0 :(得分:1)

您可以使用public function userTopRecruitsCurrMonth(){ $tempUID = array(); $mainAssocArr = array(); for ($i=0; $i < User::count(); $i++) { if($i == 0){ $offset = 0; } else{ $offset = $this->take * $i; } $users = User::take($this->take)->offset($offset)->get(); foreach ($users as $value) { $refCnts = User::where('referral', $value->aff_id)->where('signup_date', '>=', 'startDateOfCurrentMonth')->count(); if($refCnts > 0){ $tempUID['userAffID'] = $value->aff_id; $tempUID['userRecruits'] = $refCnts; $mainAssocArr[] = $tempUID; } } }//End of For loop foreach ($mainAssocArr as $key => $row) { $volume[$key] = $row['userRecruits']; $edition[$key] = $row['userAffID']; } array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $mainAssocArr); return $mainAssocArr; }

请参见下面的示例

REGEXP_CONTAINS(line, r'[./_]')

要排除所有非单词字符,可以使用#standardSQL WITH `project.dataset.table` AS ( SELECT 'Online Chat' line UNION ALL SELECT 'http://mailserver.test.com/zjalLNG391Vkfalka0' UNION ALL SELECT 'social' UNION ALL SELECT 'test.com' UNION ALL SELECT 'poc_email_outbound~51-tester-test~2018-04-12' UNION ALL SELECT 'http://mailserver.test.com/u/130931jiojf101901' ) SELECT line FROM `project.dataset.table` WHERE REGEXP_CONTAINS(line, r'[./_]') ,它等效于REGEXP_CONTAINS(line, r'\W')
您可以将后者扩展为要从条件中排除的更多字符