[Mono-bugs] [Bug 68398][Nor] New - PATCH: 2 bugs in Regex.Replace

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 14 Oct 2004 22:00:13 -0400 (EDT)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jlarimer@gmail.com.


--- shadow/68398	2004-10-14 22:00:13.000000000 -0400
+++ shadow/68398.tmp.6239	2004-10-14 22:00:13.000000000 -0400
@@ -0,0 +1,69 @@
+Bug#: 68398
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: Fedora Core 2
+Status: NEW   
+Severity: 001 One hour
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jlarimer@gmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: PATCH: 2 bugs in Regex.Replace
+Description of Problem:
+There are 2 bugs in Regex.Replace(string,string,int,int).
+The first is that when the 'startat' argument is used, the result is
+missing the text before the 'startat' position. The second bug is when a
+value of -1 is passed in the 'count' argument. In that case, the replace
+never happens. The Microsoft docs say:
+If count is negative, replacements continue to the end of the string. 
+Steps to reproduce the problem:
+compile and run this:
+using System;
+using System.Text.RegularExpressions;
+public class Test {
+        public static void Main() {
+                string teststr = "abcdeeee";
+                Regex r = new Regex("e+");
+                string result = r.Replace(teststr, "e", -1, 4);
+                Console.WriteLine("{0}", result);
+        }
+Result on MONO:
+Result on Microsoft .NET:
+How often does this happen? 
+Every time
+Additional Information:
+I'm attaching a patch that fixes both problems, and a patch for
+RegexBugs.cs unit test. (Sorry, I haven't actually tried the NUnit test,
+but I have tried the test code on Microsoft .NET and MONO, before and after
+the patch)