[Mono-dev] Regex.Match(string, int, int) behaves differently than Microsoft's implementation

Rodrigo Kumpera kumpera at gmail.com
Mon Mar 22 15:21:24 EDT 2010


On Mon, Mar 22, 2010 at 3:52 PM, Tom Philpot <tom.philpot at logos.com> wrote:

> So we've reported this bug here:
> https://bugzilla.novell.com/show_bug.cgi?id=474154
>
> Text of the bug report is as follows:
> Certain regular expressions will behave differently on Mono when calling
> Regex.Match(string, int, int). In particular the expression
>
> new Regex("^quick$").Match("The quick brown fox jumps over the lazy dog.",
> 4,
> 5).Success
>
> evaluates to true in Microsoft's implementation, but false in Mono. It
> appears
> that in Microsoft's implementation, the results of the method are
> comparable to
> calling string.Substring() on the string being passed in, except that
> indexes
> are still reported in terms of the original string.
>
> As a side note, the expression
>
> new Regex("^quick").Match("The quick brown fox jumps over the lazy dog.",
> 4).Success
>
> evaluates to false both in Microsoft's implementation and in Mono. Any fix
> to
> the former should not break the latter.
> Before I went digging into the bug, I thought I'd ask if any of the devs
> had a quick fix.
>
>
Fixing bugs in the regexp engine is really really hard given how subtle is
it's behavior.
Providing a good suite of tests is a great way forwards having it fixed.
I don`t think short-circuiting and checking for "^???$" is the right fix
since the check is
pretty complex due to other regexp rules that can be inside.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100322/a4909d5f/attachment-0001.html 


More information about the Mono-devel-list mailing list