rbkk2016
rbkk2016

Reputation: 215

Regular expression in bigquery

I want to group all the records that contains a particular word. EX: in excel how the fiter works when we give a word in the contains. Eg: mobile1, mobile, Mobile, 45-mobile, mobile station. i want all the records that contains mobile

Upvotes: 1

Views: 525

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172974

I feel that in reality your task somehow more complex - but the way you presented it makes it look relatively simple - you don't even need regular expression here
Check below example

SELECT 
  line
FROM 
  (SELECT 'I want to group all          ' AS line),
  (SELECT 'the records that             ' AS line),
  (SELECT 'contains a particular word.  ' AS line), 
  (SELECT 'EX: in excel how the fiter   ' AS line), 
  (SELECT 'works when we give a word    ' AS line), 
  (SELECT 'in the contains. Eg: mobile1,' AS line),
  (SELECT 'mobile,                      ' AS line), 
  (SELECT 'Mobile,                      ' AS line), 
  (SELECT '45-mobile,                   ' AS line), 
  (SELECT 'mobile station.              ' AS line), 
  (SELECT 'i want all the records       ' AS line), 
  (SELECT 'that contains mobile         ' AS line),
WHERE LOWER(line) CONTAINS 'mobile'

Upvotes: 1

Related Questions