Regex help

Soldato
Joined
18 Oct 2002
Posts
7,495
Location
Maidenhead
Hi all,

Looking for some help with regex please. My example data:

a) ifvmsqltestx1
b) ifvmdevx1
c) ifvmx1

I need 3 statements

1) returns when the string "test" is found e.g. only a
2) returns when the string "dev" is found e.g. only b
3) returns when neither the string "test" nor "dev" is found e.g. only c

Many thanks in advance
Alc
 
Last edited:
The regex would just be the string your searching for. If both tests 1 and 2 return false then you know the string doesnt contain either word so there's no need to test it again.

I would just use indexOf(string) in this case, you don't need the complexity that regex can give you (and, depending on your situation, indexOf might run faster anyway).
 
Hi thanks for the reply. I am using a built in regex function, not developing so I have to use regex. 1 and 2 are fine as I just use "test" or "dev", but 3 does not work as the regex has to match the value.
 
It's an SSMS plugin - apparently Any .Net regular expression is valid.

I think I may have it with (?!test)|(?!dev) - does that sound right?
 
Back
Top Bottom