[Mono-list] RegExp Bug ...

Michael Poole poole@troilus.org
04 Sep 2002 12:45:58 -0400


Hans-Jürgen Schönig <mono@cybertec.at> writes:

> 		string str = "Sunday Bloody Sunday";
> 
> 	        Regex reg = new Regex("d*.y");

Like in Perl's regexps, quantifiers modify the regexp element BEFORE
them, not after (and like Perl, quantifiers followed by ? become
non-greedy).  You need "d.*?y" if you want to match "dy" but not (for
example) "day Bloody Sunday".  "d*.y" matches zero or more 'd'
characters followed by any character followed by a 'y'.

-- Michael Poole