Regex AND'ing

I have two lines that I want to match with anything that is not equal to them, several characters can follow the first line. I tried something like this, denying two ors and denying this result.

?!(?!^.*[^Factory]$|?![^AppName]) 

Any ideas?

+4
source share
4 answers
Answer

dfa is by far the best option. But if you cannot use it for any reason, try:

 ^(?!.*Factory|AppName) 

It is very difficult to determine from your question and your regular expression what you are trying to do; they seem to imply the opposite behavior. The regular expression that I wrote will not match if Factory appears anywhere on the line or AppName appears at the beginning of it.

+3
source

Try this regex:

 (?!.*Factory$|.*AppName)^.* 

This corresponds to every line that does not end in Factory and does not contain an AppName .

+4
source

What about

 if (!match("(Factory|AppName)")) { // your code } 
+3
source

Will this work if you are looking for the existence of these two lines and then changing the regex?

0
source

All Articles