lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [2/6] lucenenet git commit: BUG: Lucene.Net.TestFramework.JavaCompatibility.SystemTypesHelpers: Fixed replaceFirst() method to match the behavior in Java that is expecting a regular expression instead of a literal to replace
Date Sun, 26 Mar 2017 03:52:44 GMT
BUG: Lucene.Net.TestFramework.JavaCompatibility.SystemTypesHelpers: Fixed replaceFirst() method
to match the behavior in Java that is expecting a regular expression instead of a literal
to replace


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/fbfcb81d
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/fbfcb81d
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/fbfcb81d

Branch: refs/heads/api-work
Commit: fbfcb81d20d55bab282cb9cdbc7d50a1ff7bd2ee
Parents: 31ceeb2
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Mar 26 04:21:16 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Mar 26 04:21:16 2017 +0700

----------------------------------------------------------------------
 .../JavaCompatibility/SystemTypesHelpers.cs                 | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fbfcb81d/src/Lucene.Net.TestFramework/JavaCompatibility/SystemTypesHelpers.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/JavaCompatibility/SystemTypesHelpers.cs b/src/Lucene.Net.TestFramework/JavaCompatibility/SystemTypesHelpers.cs
index 81dfbda..d3db4b2 100644
--- a/src/Lucene.Net.TestFramework/JavaCompatibility/SystemTypesHelpers.cs
+++ b/src/Lucene.Net.TestFramework/JavaCompatibility/SystemTypesHelpers.cs
@@ -6,6 +6,7 @@ using System.IO;
 using System.Linq;
 using System.Reflection;
 using System.Text;
+using System.Text.RegularExpressions;
 
 namespace Lucene.Net
 {
@@ -271,12 +272,8 @@ namespace Lucene.Net
 
         public static string replaceFirst(this string text, string search, string replace)
         {
-            int pos = text.IndexOf(search);
-            if (pos < 0)
-            {
-                return text;
-            }
-            return text.Substring(0, pos) + replace + text.Substring(pos + search.Length);
+            var regex = new Regex(search);
+            return regex.Replace(text, replace, 1);
         }
     }
 }


Mime
View raw message