[Mono-bugs] [Bug 675288] New: RegEx qualifier {0} differs from Microsoft implementation (and expectation)

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Feb 25 17:22:34 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=675288

https://bugzilla.novell.com/show_bug.cgi?id=675288#c0


           Summary: RegEx qualifier {0} differs from Microsoft
                    implementation (and expectation)
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: i686
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: damien at degois.info
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Created an attachment (id=416386)
 --> (http://bugzilla.novell.com/attachment.cgi?id=416386)
testREGEXP.cs

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en; rv:1.9.2.13)
Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13

Hello,

There is a difference at runtime between Mono and Microsoft interpretation of
the {0} RegExp qualifier:

The "a(?:b|c){0}c" should not match abc because of the {0}.
I have the following output on Linux:
Test #1: (expected NO match)
0:acd    1:d    
-----------------------------
Test #2: (expected 1 match)
0:ad    1:d    
Ends.

And the following one on Microsoft Windows 7 (same binary, not recompiled using
VC# nor MS csc)
Test #1: (expected NO match)
-----------------------------
Test #2: (expected 1 match)
0:ad    1:d
Ends.

I also tested it using python, and it reacts as MS interpretation.

Regards,
Damien Degois


using System;
using System.Text.RegularExpressions;

namespace testREGEXP
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Regex r;
            MatchCollection mc;

            Console.WriteLine("Test #1: (expected NO match)");
            r = new Regex("a(?:b|c){0}(d)");
            mc = r.Matches("acd");
            foreach(Match m in mc) {
                for (int i = 0; i < m.Groups.Count; i++) {
                   
Console.Write(string.Format("{0}:{1}\t",i,m.Groups[i].Value));
                }
                Console.WriteLine();
            }

            Console.WriteLine("-----------------------------");

            Console.WriteLine("Test #2: (expected 1 match)");
            r = new Regex("a(?:b|c){0}(d)");
            mc = r.Matches("ad");
            foreach(Match m in mc) {
                for (int i = 0; i < m.Groups.Count; i++) {
                   
Console.Write(string.Format("{0}:{1}\t",i,m.Groups[i].Value));
                }
                Console.WriteLine();
            }
            Console.WriteLine ("Ends.");

        }
    }
}



Reproducible: Always

Steps to Reproduce:
1. Compile the given source 
2. Run it on Linux
3. Run it on Windows
Actual Results:  
Test #1: (expected NO match)
0:acd    1:d    
-----------------------------
Test #2: (expected 1 match)
0:ad    1:d    
Ends.


Expected Results:  
Test #1: (expected NO match)
-----------------------------
Test #2: (expected 1 match)
0:ad    1:d
Ends.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list