Home > database >  Negative lookahead alternative for bigquery
Negative lookahead alternative for bigquery

Time:09-27

I'm using REGEXP_CONTAINS of Big query and want to implement it for pattern

^[-]?(?!0\d)\d*.?\d*$

But Big Query doesn't support Negative Lookahead and hence I'm looking for alternative of above pattern which is supported by Big Query. Can anyone help me with this ?

CodePudding user response:

An alternative to asserting not zero would be to just assert one through nine:

^-?(?:0|[1-9]\d*)(?:\.\d )?$

Your phrasing of an optional decimal component also needed a refactor. The above pattern is matching either an integer or decimal number which does not begin with zero.

  • Related