Reputation: 45
Here is my string (does not work in BigQuery):
name = '0.2.4'
REGEXP_MATCH(name, '^0\\.2')
More Examples:
name1 = 'com.example.dashboard'
If we write REGEXP_MATCH(name, '^com.example')
here .
is wildcard entry which is means any character
so if name1
is comaexample
it also give true.
So to skip behavior of .
we have to use \
but REGEXP_MATCH(name, '^com\\.example')
gives error.
Upvotes: 1
Views: 2765
Reputation: 26637
Try indicating that the pattern is a regular expression using r
:
SELECT REGEXP_MATCH('0.2.4', r'^0\.2')
This returns true
. The alternative is to use two slashes, as in: '^0\\.2'
Upvotes: 1
Reputation: 5511
It does work, are you sure of your name
String ?
The following query always returns true
:
SELECT REGEXP_MATCH('0.2.4', '^0.2') FROM [mydataset.mytable] LIMIT 1
Upvotes: 1