Page 2 of 2

Posted: Thu Aug 19, 2004 11:14 am
by AngryWolf
Where have you heard that in the .NET framework '|' applies only to the character it follows or the characther it preceeds? (I think alternation works on whole terms as well.)

The description of alternation constructs at Microsoft's MSDN site doesn't mention anywhere that behaviour, and I couldn't even confirm it with a regular expression tester at the DotnetCoders site. Examples:

Pattern: ^be|ar$
String: bear
Match 1: be
Match 2: ar

Pattern: ^be|ar$
String: bar
Match 1: ar

Pattern: ^b(e|a)r$
String: bar
Match 1: bar

Whatever way Microsoft is following, Unreal uses a POSIX-compliant regex library, which allows you to use the pattern "(NickServ|ChanServ)" when you want to match either "NickServ" or "ChanServ", and you don't need extra parentheses.

Posted: Thu Aug 19, 2004 9:26 pm
by aquanight
hm... my bad. I guess I'm just ()-happy :) .

Posted: Thu Aug 19, 2004 11:41 pm
by w00t
I <3 parenthese too :) They just make things easier to read I think