"Mis"-Identify blocks

These are old archives. They are kept for historic purposes only.
AngryWolf
Posts: 554
Joined: Sat Mar 06, 2004 10:53 am
Location: Hungary
Contact:

Post 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.
aquanight
Official supporter
Posts: 862
Joined: Tue Mar 09, 2004 10:47 pm
Location: Boise, ID

Post by aquanight »

hm... my bad. I guess I'm just ()-happy :) .
w00t
Posts: 1136
Joined: Thu Mar 25, 2004 3:31 am
Location: Nowra, Australia

Post by w00t »

I <3 parenthese too :) They just make things easier to read I think
-ChatSpike IRC Network [http://www.chatspike.net]
-Denora Stats [http://denora.nomadirc.net]
-Omerta [http://www.barafranca.com]
Post Reply