c# - How to match or list exactly using RegEx -


pattern: ^(?!test|abc).*$ 

i not want match test or abc only, matches test123

what need add make stop @ end?

you need use end anchor in lookahead well:

^(?!(?:test|abc)$).*$ 

then, not match test , abc whole strings, match test123.

here regex demo (using pcre engine since work same in .net 1 expression).

to apply $ end-of-string anchor both test , abc, need group them, suggest using non-capturing group (or use capturing 1 regexoptions.explicitcapture).


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -