I am using Vb.net and have following three lines and need to pick only third one leaving first and second. I tried !(REQUIRED|ESTIMATED) but it did't work.
My reg expression is !(REQUIRED|ESTIMATED) also tried but did
not work ^(REQUIRED|ESTIMATED)
09359109359REQUIRED 00000000103332014022841000099999999900000000063140000000018570
09359109359ESTIMATED00000000130452014030453000000001435000000000038560000000018570
09359109359999999999000000000058671
Regex doesn't really have a not operator like you're trying to use it. If you want to match strings that don't contain a certain word/words, you probably shouldn't use regex.
If you really want to though, for whatever reason, here's how you would solve your problem with it. You have to use a negative lookahead to check for either A or B. If A and B both aren't found, then match the whole string. This looks like this:
^(?!.*(REQUIRED|ESTIMATE)).*
The ^ symbol matches the start of the line. The (?!.*(REQUIRED|ESTIMATE))
looks ahead to see if either REQUIRED or ESTIMATE is anywhere ahead, and if so, causes to match to fail. The .* matches the rest of the string if it doesn't fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With