Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lookahead in BigQuery Regexp

It seems like BigQuery regexp does not support lookahead functionality. Does anybody know if this is correct, and if it is, is there any plan to support it sometime soon?

like image 509
user2227402 Avatar asked Jun 13 '13 14:06

user2227402


People also ask

What is a lookahead in regex?

Lookahead is used as an assertion in Python regular expressions to determine success or failure whether the pattern is ahead i.e to the right of the parser's current position. They don't match anything. Hence, they are called as zero-width assertions.

What is regex positive lookahead?

The positive lookahead construct is a pair of parentheses, with the opening parenthesis followed by a question mark and an equals sign. You can use any regular expression inside the lookahead (but not lookbehind, as explained below). Any valid regular expression can be used inside the lookahead.

What type of regex does Bigquery use?

2) BigQuery Regex: RegexP_EXTRACTRegexP_EXTRACT considers two inputs that return a substring matching a regular expression. If the regular expression contains a capturing group (matching pattern), the function will return a substring that matches the capturing group.


1 Answers

BigQuery regex uses re2. It appears that there are no plans to add lookaround assertions (or backreferences, incidentally) to re2. As far as I can tell, the hard limit on adding them is finding an adequate implementation that maintains linear running time, as guaranteed by re2.

In my opinion, though, the point at which you add backreferences or lookaround assertions to a regex is a really good time to revisit whether regex is really the right tool for the job.

like image 57
femtoRgon Avatar answered Sep 30 '22 15:09

femtoRgon