PCRE regex to Re2 Regex without negative lookahead -
i trying use regex filter emails addresses in office g suite account email routing. in order so, have created following regex in order following:
- accept email address domain "domain.com"
- reject 2 of addresses domain.
in order so, created following regex complete said function:
^(?!test|tes2)[a-z0-9._%+-]+@domain.com$
this 1 reject both test@domain.com , tes2@domain.com , accept other combinations said domain.
however, g suite not accept pcre regex, cannot achieve this.
temporarily, created following re2 regex accept email addresses said domain:
(\w|^)[\w.+\-]{0,25}@(domain)\.com(\w|$)
how can expand allow functionality intended since lookarounds not allowed in re2 regex?
because negative lookahead fixed size, it's relatively straightforward expand so. explode in complexity though; i've added comments , spacing readability.
^ ( # not /^t/ [a-su-z0-9._%+-][a-z0-9._%+-]* | # /^t/ not /^te/ t ([a-df-z0-9._%+-][a-z0-9._%+-]*)? | # /^te/ not /^tes/ te ([a-rt-z0-9._%+-][a-z0-9._%+-]*)? | # /^tes/ not /^tes[t2]/ tes ([a-su-z013-9._%+-][a-z0-9._%+-]*)? ) @domain.com $
Comments
Post a Comment