Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Negate match in RE2 syntax?

Tags:

regex

re2

How can I write a regex in RE2 for "match strings not starting with 4 or 5"?

In PCRE I'd use ^(?!4) but RE2 doesn't support that syntax.

like image 249
Richard Avatar asked Jan 28 '15 16:01

Richard


1 Answers

You can use this regex:

^[^45]

^ matches start and [^45] matches anything but 4 or 5 at start.

like image 59
anubhava Avatar answered Sep 18 '22 17:09

anubhava