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.
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.
You can use this regex:
^[^45]
^
matches start and [^45]
matches anything but 4
or 5
at start.
Here's a variant of the solution for strings of words, not individual characters.
The way I do it is to look twice.
First, find all the items that match, then filter them to get the final answer
aaabaraaa
aaafooaaa
aaazooaaa
aaaqooaaa
suppose I want to find center text(between "aaa"), and it should not be "bar" or "foo"it's easy with PCRE1 => https://regex101.com/r/nJcbt1/1/
use re2 I will choose divide and conquer: To a reduced scope with the group, and then filter.
a solution writing with Golang =>
[1] PCRE: Perl Compatible Regular Expressions