RegEx
-
Hey Guys I'm using the RegEx to do some pattern matching, but I'm after finding one of 2 specific strings. At the moment I'm using
Regex reg1 = new Regex("FIRST[ ]+STRING");Regex reg2 = new Regex("SECOND[ ]+STRING");
Is there a way I could get the Regular Expression to say match exact string A OR exact string B in the same statement? (egRegex exp = new Regex("ThisString or ThisString");
Thank you in advance :-Doooo, the Jedi's will feel this one....
-
Hey Guys I'm using the RegEx to do some pattern matching, but I'm after finding one of 2 specific strings. At the moment I'm using
Regex reg1 = new Regex("FIRST[ ]+STRING");Regex reg2 = new Regex("SECOND[ ]+STRING");
Is there a way I could get the Regular Expression to say match exact string A OR exact string B in the same statement? (egRegex exp = new Regex("ThisString or ThisString");
Thank you in advance :-Doooo, the Jedi's will feel this one....
Regex exp = new Regex("(ThisString)|(ThatString)");
Will do it nicely.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
Hey Guys I'm using the RegEx to do some pattern matching, but I'm after finding one of 2 specific strings. At the moment I'm using
Regex reg1 = new Regex("FIRST[ ]+STRING");Regex reg2 = new Regex("SECOND[ ]+STRING");
Is there a way I could get the Regular Expression to say match exact string A OR exact string B in the same statement? (egRegex exp = new Regex("ThisString or ThisString");
Thank you in advance :-Doooo, the Jedi's will feel this one....
Before I forget - have a look at Expresso[^] - it examines, creates and explains regular expressions. It works, it helps you understand how they work, and it's free.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
Regex exp = new Regex("(ThisString)|(ThatString)");
Will do it nicely.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
Thats it??? :doh: So simple. I'm kicking myself now. Thank you.
oooo, the Jedi's will feel this one....
-
Before I forget - have a look at Expresso[^] - it examines, creates and explains regular expressions. It works, it helps you understand how they work, and it's free.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
Excellent. Thanks. I'm new to regular expressions, and they appear very alien so far. Muchas Gracias :-D
oooo, the Jedi's will feel this one....
-
Thats it??? :doh: So simple. I'm kicking myself now. Thank you.
oooo, the Jedi's will feel this one....
You're welcome - technically you don't need the brackets, but I always feel they help to make it more readable (if a regex can be described as readable... :laugh: )
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy