lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [02/11] lucenenet git commit: BUG: Patched behavior of all implementations of String.Split() and Regex.Split() using the .TrimEnd() extension method. In Java, only the empty entries at the end of the array are removed, not all empty entries.
Date Fri, 22 Sep 2017 05:55:25 GMT
BUG: Patched behavior of all implementations of String.Split() and Regex.Split() using the .TrimEnd() extension method. In Java, only the empty entries at the end of the array are removed, not all empty entries.


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

Branch: refs/heads/master
Commit: a57d9f1154b7393556493e73e4a9649d28df1f0a
Parents: caa61a3
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Tue Sep 19 19:40:00 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Fri Sep 22 03:06:02 2017 +0700

----------------------------------------------------------------------
 .../Analysis/Hunspell/Dictionary.cs               | 18 +++++++++---------
 .../Hunspell/HunspellStemFilterFactory.cs         |  3 ++-
 .../Analysis/Miscellaneous/PatternAnalyzer.cs     |  4 ++--
 .../Analysis/Pt/RSLPStemmerBase.cs                |  2 +-
 .../Analysis/Util/WordlistLoader.cs               | 11 ++++++++---
 .../Dict/UserDictionary.cs                        |  6 +++---
 .../Tools/CharacterDefinitionWriter.cs            |  6 +++---
 .../Tools/ConnectionCostsBuilder.cs               |  7 ++++---
 .../Tools/UnknownDictionaryBuilder.cs             |  5 +++--
 .../Language/Bm/Lang.cs                           |  4 ++--
 .../Language/Bm/PhoneticEngine.cs                 |  4 ++--
 .../Language/Bm/Rule.cs                           |  6 +++---
 .../Language/DaitchMokotoffSoundex.cs             | 14 +++++++++-----
 .../ByTask/Feeds/LineDocSource.cs                 |  2 +-
 .../ByTask/Tasks/OpenReaderTask.cs                |  2 +-
 .../SimpleText/SimpleTextDocValuesReader.cs       |  5 +++--
 .../JS/JavascriptCompiler.cs                      |  2 +-
 src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs     |  2 +-
 .../Xml/Builders/LikeThisQueryBuilder.cs          |  3 ++-
 .../Http/ReplicationService.cs                    |  3 ++-
 .../IndexAndTaxonomyRevision.cs                   |  3 ++-
 .../Analysis/VocabularyAssert.cs                  |  4 ++--
 .../Randomized/SeedUtils.cs                       |  3 ++-
 .../TestRemoveDuplicatesTokenFilter.cs            |  2 +-
 .../TestRemoveDuplicatesTokenFilterFactory.cs     |  3 ++-
 .../Snowball/TestSnowballPorterFilterFactory.cs   |  3 ++-
 .../Analysis/Synonym/TestSlowSynonymFilter.cs     |  8 ++++----
 .../Analysis/Synonym/TestSynonymMapFilter.cs      | 12 ++++++------
 .../Analysis/Util/TestCharTokenizers.cs           |  2 +-
 .../TestJapaneseTokenizer.cs                      |  3 ++-
 .../TestSearchMode.cs                             |  7 ++++---
 .../Language/Bm/BeiderMorseEncoderTest.cs         |  5 +++--
 .../Language/Bm/PhoneticEngineRegressionTest.cs   |  2 +-
 .../Language/Bm/PhoneticEngineTest.cs             |  9 +++++----
 .../WriterCache/TestCompactLabelToOrdinal.cs      | 11 ++++++-----
 .../ComplexPhrase/TestComplexPhraseQuery.cs       |  3 ++-
 .../Queries/TestSlowFuzzyQuery2.cs                |  4 ++--
 src/Lucene.Net.Tests.Spatial/SpatialTestData.cs   |  5 +++--
 .../Analyzing/AnalyzingInfixSuggesterTest.cs      |  4 ++--
 .../Suggest/Analyzing/AnalyzingSuggesterTest.cs   |  2 +-
 .../Suggest/Analyzing/FuzzySuggesterTest.cs       |  2 +-
 .../Analysis/TestGraphTokenizers.cs               |  4 ++--
 src/Lucene.Net.Tests/Index/TestDuelingCodecs.cs   |  2 +-
 src/Lucene.Net.Tests/Index/TestIndexWriter.cs     |  2 +-
 .../Search/Payloads/TestPayloadNearQuery.cs       |  4 ++--
 .../Search/TestSloppyPhraseQuery.cs               | 12 +++++++++---
 .../Search/TestTimeLimitingCollector.cs           |  4 +++-
 src/Lucene.Net/Support/StringExtensions.cs        |  4 ----
 48 files changed, 134 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs b/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs
index 0c7c8c1..55037ff 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs
@@ -309,7 +309,7 @@ namespace Lucene.Net.Analysis.Hunspell
                 }
                 else if (line.StartsWith(CIRCUMFIX_KEY, StringComparison.Ordinal))
                 {
-                    string[] parts = whitespacePattern.Split(line);
+                    string[] parts = whitespacePattern.Split(line).TrimEnd();
                     if (parts.Length != 2)
                     {
                         throw new Exception(string.Format("Illegal CIRCUMFIX declaration, line {0}", lineNumber));
@@ -318,7 +318,7 @@ namespace Lucene.Net.Analysis.Hunspell
                 }
                 else if (line.StartsWith(IGNORE_KEY, StringComparison.Ordinal))
                 {
-                    string[] parts = whitespacePattern.Split(line);
+                    string[] parts = whitespacePattern.Split(line).TrimEnd();
                     if (parts.Length != 2)
                     {
                         throw new Exception(string.Format("Illegal IGNORE declaration, line {0}", lineNumber));
@@ -329,7 +329,7 @@ namespace Lucene.Net.Analysis.Hunspell
                 }
                 else if (line.StartsWith(ICONV_KEY, StringComparison.Ordinal) || line.StartsWith(OCONV_KEY, StringComparison.Ordinal))
                 {
-                    string[] parts = whitespacePattern.Split(line);
+                    string[] parts = whitespacePattern.Split(line).TrimEnd();
                     string type = parts[0];
                     if (parts.Length != 2)
                     {
@@ -407,7 +407,7 @@ namespace Lucene.Net.Analysis.Hunspell
         {
             BytesRef scratch = new BytesRef();
             StringBuilder sb = new StringBuilder();
-            string[] args = whitespacePattern.Split(header);
+            string[] args = whitespacePattern.Split(header).TrimEnd();
 
             bool crossProduct = args[2].Equals("Y");
 
@@ -419,7 +419,7 @@ namespace Lucene.Net.Analysis.Hunspell
             {
                 Debug.Assert(affixWriter.Position == currentAffix << 3);
                 string line = reader.ReadLine();
-                string[] ruleArgs = whitespacePattern.Split(line);
+                string[] ruleArgs = whitespacePattern.Split(line).TrimEnd();
 
                 // from the manpage: PFX flag stripping prefix [condition [morphological_fields...]]
                 // condition is optional
@@ -554,7 +554,7 @@ namespace Lucene.Net.Analysis.Hunspell
             for (int i = 0; i < num; i++)
             {
                 string line = reader.ReadLine();
-                string[] parts = whitespacePattern.Split(line);
+                string[] parts = whitespacePattern.Split(line).TrimEnd();
                 if (parts.Length != 3)
                 {
                     throw new Exception("invalid syntax: " + line /*, reader.LineNumber */); // LUCENENET TODO: LineNumberReader
@@ -683,7 +683,7 @@ namespace Lucene.Net.Analysis.Hunspell
         /// <returns> <see cref="FlagParsingStrategy"/> that handles parsing flags in the way specified in the FLAG definition </returns>
         internal static FlagParsingStrategy GetFlagParsingStrategy(string flagLine)
         {
-            string[] parts = whitespacePattern.Split(flagLine);
+            string[] parts = whitespacePattern.Split(flagLine).TrimEnd();
             if (parts.Length != 2)
             {
                 throw new System.ArgumentException("Illegal FLAG specification: " + flagLine);
@@ -982,7 +982,7 @@ namespace Lucene.Net.Analysis.Hunspell
 
         private void ParseAlias(string line)
         {
-            string[] ruleArgs = whitespacePattern.Split(line);
+            string[] ruleArgs = whitespacePattern.Split(line).TrimEnd();
             if (aliases == null)
             {
                 //first line should be the aliases count
@@ -1057,7 +1057,7 @@ namespace Lucene.Net.Analysis.Hunspell
         {
             internal override char[] ParseFlags(string rawFlags)
             {
-                string[] rawFlagParts = rawFlags.Trim().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+                string[] rawFlagParts = rawFlags.Trim().Split(',').TrimEnd();
                 char[] flags = new char[rawFlagParts.Length];
                 int upto = 0;
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/HunspellStemFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/HunspellStemFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/HunspellStemFilterFactory.cs
index d27fa3b..eef53a4 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/HunspellStemFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/HunspellStemFilterFactory.cs
@@ -1,4 +1,5 @@
 using Lucene.Net.Analysis.Util;
+using Lucene.Net.Support;
 using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
@@ -76,7 +77,7 @@ namespace Lucene.Net.Analysis.Hunspell
 
         public virtual void Inform(IResourceLoader loader)
         {
-            string[] dicts = dictionaryFiles.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+            string[] dicts = dictionaryFiles.Split(',').TrimEnd();
 
             Stream affix = null;
             IList<Stream> dictionaries = new List<Stream>();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/PatternAnalyzer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/PatternAnalyzer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/PatternAnalyzer.cs
index 69fa5fb..bc596e2 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/PatternAnalyzer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/PatternAnalyzer.cs
@@ -29,7 +29,7 @@ namespace Lucene.Net.Analysis.Miscellaneous
     /// <summary>
     /// Efficient Lucene analyzer/tokenizer that preferably operates on a <see cref="string"/> rather than a
     /// <see cref="TextReader"/>, that can flexibly separate text into terms via a regular expression <see cref="Regex"/>
-    /// (with behaviour similar to <see cref="string.Split(string[], StringSplitOptions)"/>),
+    /// (with behaviour similar to <see cref="Regex.Split(string)"/>),
     /// and that combines the functionality of
     /// <see cref="LetterTokenizer"/>,
     /// <see cref="LowerCaseTokenizer"/>,
@@ -39,7 +39,7 @@ namespace Lucene.Net.Analysis.Miscellaneous
     /// <para>
     /// If you are unsure how exactly a regular expression should look like, consider 
     /// prototyping by simply trying various expressions on some test texts via
-    /// <see cref="string.Split(string[], StringSplitOptions)"/>. Once you are satisfied, give that regex to 
+    /// <see cref="Regex.Split(string)"/>. Once you are satisfied, give that regex to 
     /// <see cref="PatternAnalyzer"/>. Also see <a target="_blank" 
     /// href="http://www.regular-expressions.info/">Regular Expression Tutorial</a>.
     /// </para>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Common/Analysis/Pt/RSLPStemmerBase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Pt/RSLPStemmerBase.cs b/src/Lucene.Net.Analysis.Common/Analysis/Pt/RSLPStemmerBase.cs
index e36aee8..26f3c59 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Pt/RSLPStemmerBase.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Pt/RSLPStemmerBase.cs
@@ -364,7 +364,7 @@ namespace Lucene.Net.Analysis.Pt
             {
                 return null;
             }
-            string[] list = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+            string[] list = s.Split(',').TrimEnd();
             for (int i = 0; i < list.Length; i++)
             {
                 list[i] = ParseString(list[i].Trim());

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Common/Analysis/Util/WordlistLoader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/WordlistLoader.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/WordlistLoader.cs
index 23fa016..5281f5f 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/WordlistLoader.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/WordlistLoader.cs
@@ -1,9 +1,11 @@
-using Lucene.Net.Util;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Text;
+using System.Text.RegularExpressions;
 
 namespace Lucene.Net.Analysis.Util
 {
@@ -34,6 +36,9 @@ namespace Lucene.Net.Analysis.Util
     {
         private const int INITIAL_CAPACITY = 16;
 
+        // LUCENENET specific
+        private readonly static Regex WHITESPACE = new Regex("\\s+", RegexOptions.Compiled);
+
         /// <summary>
         /// no instance </summary>
         private WordlistLoader()
@@ -155,7 +160,7 @@ namespace Lucene.Net.Analysis.Util
                     {
                         line = line.Substring(0, comment);
                     }
-                    string[] words = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(w => w.Trim()).ToArray();
+                    string[] words = WHITESPACE.Split(line).TrimEnd();
                     foreach (var word in words)
                     {
                         if (word.Length > 0)
@@ -206,7 +211,7 @@ namespace Lucene.Net.Analysis.Util
                 string line;
                 while ((line = reader.ReadLine()) != null)
                 {
-                    string[] wordstem = line.Split(new char[] { '\t' }, 2, StringSplitOptions.RemoveEmptyEntries);
+                    string[] wordstem = line.Split(new char[] { '\t' }, 2);
                     result.Put(wordstem[0], wordstem[1]);
                 }
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Kuromoji/Dict/UserDictionary.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Kuromoji/Dict/UserDictionary.cs b/src/Lucene.Net.Analysis.Kuromoji/Dict/UserDictionary.cs
index 3fb2b09..d5853c0 100644
--- a/src/Lucene.Net.Analysis.Kuromoji/Dict/UserDictionary.cs
+++ b/src/Lucene.Net.Analysis.Kuromoji/Dict/UserDictionary.cs
@@ -88,8 +88,8 @@ namespace Lucene.Net.Analysis.Ja.Dict
 
             foreach (string[] values in featureEntries)
             {
-                string[] segmentation = commentLine.Replace(values[1], " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
-                string[] readings = commentLine.Replace(values[2], " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+                string[] segmentation = commentLine.Replace(values[1], " ").Split(' ').TrimEnd();
+                string[] readings = commentLine.Replace(values[2], " ").Split(' ').TrimEnd();
                 string pos = values[3];
 
                 if (segmentation.Length != readings.Length)
@@ -265,7 +265,7 @@ namespace Lucene.Net.Analysis.Ja.Dict
                 return null;
             }
 
-            return allFeatures.Split(new string[] { Dictionary.INTERNAL_SEPARATOR }, StringSplitOptions.RemoveEmptyEntries);
+            return allFeatures.Split(new string[] { Dictionary.INTERNAL_SEPARATOR }, StringSplitOptions.None).TrimEnd();
         }
 
         private string GetFeature(int wordId, params int[] fields)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Kuromoji/Tools/CharacterDefinitionWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Kuromoji/Tools/CharacterDefinitionWriter.cs b/src/Lucene.Net.Analysis.Kuromoji/Tools/CharacterDefinitionWriter.cs
index 39ed4f8..9f019fb 100644
--- a/src/Lucene.Net.Analysis.Kuromoji/Tools/CharacterDefinitionWriter.cs
+++ b/src/Lucene.Net.Analysis.Kuromoji/Tools/CharacterDefinitionWriter.cs
@@ -46,9 +46,9 @@ namespace Lucene.Net.Analysis.Ja.Util
         /// <param name="characterClassName">Character class name.</param>
         public void PutCharacterCategory(int codePoint, string characterClassName)
         {
-            characterClassName = characterClassName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0]; // use first
-                                                                                                                         // category
-                                                                                                                         // class
+            characterClassName = characterClassName.Split(' ')[0]; // use first
+                                                                    // category
+                                                                    // class
 
             // Override Nakaguro
             if (codePoint == 0x30FB)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Kuromoji/Tools/ConnectionCostsBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Kuromoji/Tools/ConnectionCostsBuilder.cs b/src/Lucene.Net.Analysis.Kuromoji/Tools/ConnectionCostsBuilder.cs
index 235c523..49aa559 100644
--- a/src/Lucene.Net.Analysis.Kuromoji/Tools/ConnectionCostsBuilder.cs
+++ b/src/Lucene.Net.Analysis.Kuromoji/Tools/ConnectionCostsBuilder.cs
@@ -1,4 +1,5 @@
-using System.Diagnostics;
+using Lucene.Net.Support;
+using System.Diagnostics;
 using System.Globalization;
 using System.IO;
 using System.Text;
@@ -38,7 +39,7 @@ namespace Lucene.Net.Analysis.Ja.Util
                 StreamReader streamReader = new StreamReader(inputStream, Encoding.ASCII);
 
                 string line = streamReader.ReadLine();
-                string[] dimensions = whiteSpaceRegex.Split(line);
+                string[] dimensions = whiteSpaceRegex.Split(line).TrimEnd();
 
                 Debug.Assert(dimensions.Length == 2);
 
@@ -51,7 +52,7 @@ namespace Lucene.Net.Analysis.Ja.Util
 
                 while ((line = streamReader.ReadLine()) != null)
                 {
-                    string[] fields = whiteSpaceRegex.Split(line);
+                    string[] fields = whiteSpaceRegex.Split(line).TrimEnd();
 
                     Debug.Assert(fields.Length == 3);
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Kuromoji/Tools/UnknownDictionaryBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Kuromoji/Tools/UnknownDictionaryBuilder.cs b/src/Lucene.Net.Analysis.Kuromoji/Tools/UnknownDictionaryBuilder.cs
index 7f10b9b..e57570a 100644
--- a/src/Lucene.Net.Analysis.Kuromoji/Tools/UnknownDictionaryBuilder.cs
+++ b/src/Lucene.Net.Analysis.Kuromoji/Tools/UnknownDictionaryBuilder.cs
@@ -1,4 +1,5 @@
 using Lucene.Net.Analysis.Ja.Dict;
+using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
 using System.Globalization;
@@ -120,7 +121,7 @@ namespace Lucene.Net.Analysis.Ja.Util
                         }
                         else
                         {
-                            string[] codePoints = Regex.Split(values[0], "\\.\\.");
+                            string[] codePoints = Regex.Split(values[0], "\\.\\.").TrimEnd();
                             int cpFrom = Convert.ToInt32(codePoints[0], 16);
                             int cpTo = Convert.ToInt32(codePoints[1], 16);
 
@@ -132,7 +133,7 @@ namespace Lucene.Net.Analysis.Ja.Util
                     }
                     else
                     {  // Invoke definition
-                        string[] values = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); // Consecutive space is merged above
+                        string[] values = line.Split(' ').TrimEnd(); // Consecutive space is merged above
                         string characterClassName = values[0];
                         int invoke = int.Parse(values[1], CultureInfo.InvariantCulture);
                         int group = int.Parse(values[2], CultureInfo.InvariantCulture);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Lang.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Lang.cs b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Lang.cs
index 98119f8..63faf7c 100644
--- a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Lang.cs
+++ b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Lang.cs
@@ -190,7 +190,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
                             }
 
                             // split it up
-                            string[] parts = WHITESPACE.Split(line);
+                            string[] parts = WHITESPACE.Split(line).TrimEnd();
 
                             if (parts.Length != 3)
                             {
@@ -199,7 +199,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
                             }
 
                             Regex pattern = new Regex(parts[0], RegexOptions.Compiled);
-                            string[] langs = TOKEN.Split(parts[1]);
+                            string[] langs = TOKEN.Split(parts[1]).TrimEnd();
                             bool accept = parts[2].Equals("true");
 
                             rules.Add(new LangRule(pattern, new HashSet<string>(langs), accept));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Phonetic/Language/Bm/PhoneticEngine.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/PhoneticEngine.cs b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/PhoneticEngine.cs
index 3cf5c7a..1288f6b 100644
--- a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/PhoneticEngine.cs
+++ b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/PhoneticEngine.cs
@@ -464,7 +464,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
                 }
             }
 
-            IList<string> words = WHITESPACE.Split(input).ToList();
+            IList<string> words = WHITESPACE.Split(input).TrimEnd().ToList();
             IList<string> words2 = new List<string>();
 
             // special-case handling of word prefixes based upon the name type
@@ -473,7 +473,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
                 case NameType.SEPHARDIC:
                     foreach (string aWord in words)
                     {
-                        string[] parts = aWord.Split(new char[] { '\'' }, StringSplitOptions.RemoveEmptyEntries);
+                        string[] parts = aWord.Split('\'').TrimEnd();
                         string lastPart = parts[parts.Length - 1];
                         words2.Add(lastPart);
                     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs
index 52f3d9a..55e2d17 100644
--- a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs
+++ b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs
@@ -355,7 +355,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
                 }
                 string before = ph.Substring(0, open - 0);
                 string input = ph.Substring(open + 1, (ph.Length - 1) - (open + 1));
-                ISet<string> langs = new HashSet<string>(PLUS.Split(input));
+                ISet<string> langs = new HashSet<string>(PLUS.Split(input).TrimEnd());
 
                 return new Phoneme(before, LanguageSet.From(langs));
             }
@@ -376,7 +376,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
 
                 IList<Phoneme> phs = new List<Phoneme>();
                 string body = ph.Substring(1, (ph.Length - 1) - 1);
-                foreach (string part in PIPE.Split(body))
+                foreach (string part in PIPE.Split(body).TrimEnd())
                 {
                     phs.Add(ParsePhoneme(part));
                 }
@@ -477,7 +477,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
                             else
                             {
                                 // rule
-                                string[] parts = WHITESPACE.Split(line);
+                                string[] parts = WHITESPACE.Split(line).TrimEnd();
                                 if (parts.Length != 4)
                                 {
                                     throw new ArgumentException("Malformed rule statement split into " + parts.Length +

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs b/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs
index e72bc38..d6bdfcb 100644
--- a/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs
+++ b/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs
@@ -160,6 +160,8 @@ namespace Lucene.Net.Analysis.Phonetic.Language
         /// </summary>
         private sealed class Rule
         {
+            private readonly static Regex PIPE = new Regex(@"\|", RegexOptions.Compiled);
+
             private readonly string pattern;
             private readonly string[] replacementAtStart;
             private readonly string[] replacementBeforeVowel;
@@ -169,9 +171,9 @@ namespace Lucene.Net.Analysis.Phonetic.Language
                     string replacementDefault)
             {
                 this.pattern = pattern;
-                this.replacementAtStart = Regex.Split(replacementAtStart, "\\|");
-                this.replacementBeforeVowel = Regex.Split(replacementBeforeVowel, "\\|");
-                this.replacementDefault = Regex.Split(replacementDefault, "\\|");
+                this.replacementAtStart = PIPE.Split(replacementAtStart);
+                this.replacementBeforeVowel = PIPE.Split(replacementBeforeVowel);
+                this.replacementDefault = PIPE.Split(replacementDefault);
             }
 
             // LUCENENET specific - need read access to pattern
@@ -238,6 +240,8 @@ namespace Lucene.Net.Analysis.Phonetic.Language
         /// <summary>Folding rules.</summary>
         private static readonly IDictionary<char, char> FOLDINGS = new Dictionary<char, char>();
 
+        private static readonly Regex WHITESPACE = new Regex(@"\s+", RegexOptions.Compiled);
+
         private class DaitchMokotoffRuleComparer : IComparer<Rule>
         {
             public int Compare(Rule rule1, Rule rule2)
@@ -312,7 +316,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language
                     if (line.Contains("="))
                     {
                         // folding
-                        string[] parts = line.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
+                        string[] parts = line.Split('=').TrimEnd();
                         if (parts.Length != 2)
                         {
                             throw new ArgumentException("Malformed folding statement split into " + parts.Length +
@@ -335,7 +339,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language
                     else
                     {
                         // rule
-                        string[] parts = Regex.Split(line, "\\s+");
+                        string[] parts = WHITESPACE.Split(line).TrimEnd();
                         if (parts.Length != 4)
                         {
                             throw new ArgumentException("Malformed rule statement split into " + parts.Length +

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Benchmark/ByTask/Feeds/LineDocSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Benchmark/ByTask/Feeds/LineDocSource.cs b/src/Lucene.Net.Benchmark/ByTask/Feeds/LineDocSource.cs
index 1a45cc6..8829b75 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Feeds/LineDocSource.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Feeds/LineDocSource.cs
@@ -123,7 +123,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Feeds
 
             if (line.StartsWith(headIndicator, StringComparison.Ordinal))
             {
-                header = line.Substring(headIndicator.Length).Split(new char[] { WriteLineDocTask.SEP }).TrimEnd();
+                header = line.Substring(headIndicator.Length).Split(WriteLineDocTask.SEP).TrimEnd();
                 skipHeaderLine = true; // mark to skip the header line when input file is reopened
             }
             else

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Benchmark/ByTask/Tasks/OpenReaderTask.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Benchmark/ByTask/Tasks/OpenReaderTask.cs b/src/Lucene.Net.Benchmark/ByTask/Tasks/OpenReaderTask.cs
index 81adf4c..7ef8705 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Tasks/OpenReaderTask.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Tasks/OpenReaderTask.cs
@@ -63,7 +63,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Tasks
             base.SetParams(@params);
             if (@params != null)
             {
-                string[] split = @params.Split(new char[] { ',' }).TrimEnd();
+                string[] split = @params.Split(',').TrimEnd();
                 if (split.Length > 0)
                 {
                     commitUserData = split[0];

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
index a928290..fe493c6 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
@@ -1,4 +1,5 @@
-using System;
+using Lucene.Net.Support;
+using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Globalization;
@@ -535,7 +536,7 @@ namespace Lucene.Net.Codecs.SimpleText
                                 docID * (1 + _field.OrdPattern.Length));
                     SimpleTextUtil.ReadLine(_input, _scratch);
                     var ordList = _scratch.Utf8ToString().Trim();
-                    _currentOrds = ordList.Length == 0 ? new string[0] : ordList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+                    _currentOrds = ordList.Length == 0 ? new string[0] : ordList.Split(',').TrimEnd();
                     _currentIndex = 0;
                 }
                 catch (System.IO.IOException ioe)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Expressions/JS/JavascriptCompiler.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Expressions/JS/JavascriptCompiler.cs b/src/Lucene.Net.Expressions/JS/JavascriptCompiler.cs
index c95c056..4c881c8 100644
--- a/src/Lucene.Net.Expressions/JS/JavascriptCompiler.cs
+++ b/src/Lucene.Net.Expressions/JS/JavascriptCompiler.cs
@@ -608,7 +608,7 @@ namespace Lucene.Net.Expressions.JS
             {
                 foreach (var property in GetDefaultSettings())
                 {
-                    string[] vals = property.Value.Split(',');
+                    string[] vals = property.Value.Split(',').TrimEnd();
                     if (vals.Length != 3)
                     {
                         throw new Exception("Error reading Javascript functions from settings");

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs b/src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs
index 870771f..6d811db 100644
--- a/src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/CategoryPath.cs
@@ -90,7 +90,7 @@ namespace Lucene.Net.Facet.Taxonomy
         /// </summary>
         public CategoryPath(string pathString, char delimiter)
         {
-            string[] comps = pathString.Split(new[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);
+            string[] comps = pathString.Split(delimiter).TrimEnd();
             if (comps.Length == 1 && comps[0].Length == 0)
             {
                 Components = null;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.QueryParser/Xml/Builders/LikeThisQueryBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Xml/Builders/LikeThisQueryBuilder.cs b/src/Lucene.Net.QueryParser/Xml/Builders/LikeThisQueryBuilder.cs
index 0af6739..88015da 100644
--- a/src/Lucene.Net.QueryParser/Xml/Builders/LikeThisQueryBuilder.cs
+++ b/src/Lucene.Net.QueryParser/Xml/Builders/LikeThisQueryBuilder.cs
@@ -2,6 +2,7 @@
 using Lucene.Net.Analysis.TokenAttributes;
 using Lucene.Net.Queries.Mlt;
 using Lucene.Net.Search;
+using Lucene.Net.Support;
 using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
@@ -55,7 +56,7 @@ namespace Lucene.Net.QueryParsers.Xml.Builders
             string[] fields = defaultFieldNames;
             if ((fieldsList != null) && (fieldsList.Trim().Length > 0))
             {
-                fields = fieldsList.Trim().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+                fields = fieldsList.Trim().Split(',').TrimEnd();
                 //trim the fieldnames
                 for (int i = 0; i < fields.Length; i++)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Replicator/Http/ReplicationService.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Replicator/Http/ReplicationService.cs b/src/Lucene.Net.Replicator/Http/ReplicationService.cs
index 6ef6155..38692f9 100644
--- a/src/Lucene.Net.Replicator/Http/ReplicationService.cs
+++ b/src/Lucene.Net.Replicator/Http/ReplicationService.cs
@@ -1,5 +1,6 @@
 using Lucene.Net.Replicator.Http.Abstractions;
 using Lucene.Net.Support.IO;
+using Lucene.Net.Support;
 using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
@@ -111,7 +112,7 @@ namespace Lucene.Net.Replicator.Http
             if (path.Length > actionLength && path[actionLength] == '/')
                 ++startIndex;
 
-            return path.Substring(startIndex).Split('/');
+            return path.Substring(startIndex).Split('/').TrimEnd();
         }
 
         private static string ExtractRequestParam(IReplicationRequest request, string paramName)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Replicator/IndexAndTaxonomyRevision.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Replicator/IndexAndTaxonomyRevision.cs b/src/Lucene.Net.Replicator/IndexAndTaxonomyRevision.cs
index b2b90a6..de1ed16 100644
--- a/src/Lucene.Net.Replicator/IndexAndTaxonomyRevision.cs
+++ b/src/Lucene.Net.Replicator/IndexAndTaxonomyRevision.cs
@@ -2,6 +2,7 @@
 using Lucene.Net.Facet.Taxonomy.WriterCache;
 using Lucene.Net.Index;
 using Lucene.Net.Store;
+using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
@@ -150,7 +151,7 @@ namespace Lucene.Net.Replicator
         /// </summary>
         public virtual int CompareTo(string version)
         {
-            string[] parts = version.Split(':');
+            string[] parts = version.Split(':').TrimEnd();
             long indexGen = long.Parse(parts[0], NumberStyles.HexNumber);
             long taxonomyGen = long.Parse(parts[1], NumberStyles.HexNumber);
             long indexCommitGen = indexCommit.Generation;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.TestFramework/Analysis/VocabularyAssert.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Analysis/VocabularyAssert.cs b/src/Lucene.Net.TestFramework/Analysis/VocabularyAssert.cs
index 7ce652b..749260f 100644
--- a/src/Lucene.Net.TestFramework/Analysis/VocabularyAssert.cs
+++ b/src/Lucene.Net.TestFramework/Analysis/VocabularyAssert.cs
@@ -1,4 +1,4 @@
-using Lucene.Net.Util;
+using Lucene.Net.Support;
 using NUnit.Framework;
 using System.IO;
 using System.IO.Compression;
@@ -54,7 +54,7 @@ namespace Lucene.Net.Analysis
                 {
                     continue; // comment
                 }
-                string[] words = inputLine.Split('\t');
+                string[] words = inputLine.Split('\t').TrimEnd();
                 BaseTokenStreamTestCase.CheckOneTerm(a, words[0], words[1]);
             }
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.TestFramework/Randomized/SeedUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Randomized/SeedUtils.cs b/src/Lucene.Net.TestFramework/Randomized/SeedUtils.cs
index 68b5ef4..284323d 100644
--- a/src/Lucene.Net.TestFramework/Randomized/SeedUtils.cs
+++ b/src/Lucene.Net.TestFramework/Randomized/SeedUtils.cs
@@ -19,6 +19,7 @@
  *
 */
 
+using Lucene.Net.Support;
 using System;
 using System.Linq;
 using System.Text;
@@ -70,7 +71,7 @@ namespace Lucene.Net.Randomized
             if (matches.Count == 0)
                 throw new ArgumentException("Not a valid seed chain: " + chain, "chain");
 
-            var parts = chain.Split(":".ToCharArray());
+            var parts = chain.Split(':').TrimEnd();
             int[] result = new int[parts.Length];
 
             for (int i = 0; i < parts.Length; i++)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilter.cs
index 7634702..290441d 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilter.cs
@@ -51,7 +51,7 @@ namespace Lucene.Net.Analysis.Miscellaneous
             IEnumerator<Token> toks = Arrays.AsList(tokens).GetEnumerator();
             TokenStream ts = new RemoveDuplicatesTokenFilter((new TokenStreamAnonymousInnerClassHelper(this, toks)));
 
-            AssertTokenStreamContents(ts, Regex.Split(expected, "\\s"));
+            AssertTokenStreamContents(ts, Regex.Split(expected, "\\s").TrimEnd());
         }
 
         private class TokenStreamAnonymousInnerClassHelper : TokenStream

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs
index 0113e09..c75be08 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs
@@ -1,4 +1,5 @@
 using Lucene.Net.Analysis.Util;
+using Lucene.Net.Support;
 using NUnit.Framework;
 using System.Text.RegularExpressions;
 
@@ -37,7 +38,7 @@ namespace Lucene.Net.Analysis.Miscellaneous
         {
             TokenStream stream = new CannedTokenStream(tokens);
             stream = TokenFilterFactory("RemoveDuplicates").Create(stream);
-            AssertTokenStreamContents(stream, Regex.Split(expected, "\\s"));
+            AssertTokenStreamContents(stream, Regex.Split(expected, "\\s").TrimEnd());
         }
 
         [Test]

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Common/Analysis/Snowball/TestSnowballPorterFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Snowball/TestSnowballPorterFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Snowball/TestSnowballPorterFilterFactory.cs
index 4f112b2..1de2510 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Snowball/TestSnowballPorterFilterFactory.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Snowball/TestSnowballPorterFilterFactory.cs
@@ -1,4 +1,5 @@
 using Lucene.Net.Analysis.Util;
+using Lucene.Net.Support;
 using Lucene.Net.Tartarus.Snowball.Ext;
 using NUnit.Framework;
 using System.IO;
@@ -32,7 +33,7 @@ namespace Lucene.Net.Analysis.Snowball
         {
             string text = "The fledgling banks were counting on a big boom in banking";
             EnglishStemmer stemmer = new EnglishStemmer();
-            string[] test = Regex.Split(text, "\\s");
+            string[] test = Regex.Split(text, "\\s").TrimEnd();
             string[] gold = new string[test.Length];
             for (int i = 0; i < test.Length; i++)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSlowSynonymFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSlowSynonymFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSlowSynonymFilter.cs
index 7d33bd9..c2cf39b 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSlowSynonymFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSlowSynonymFilter.cs
@@ -37,7 +37,7 @@ namespace Lucene.Net.Analysis.Synonym
 
         internal static IList<string> Strings(string str)
         {
-            string[] arr = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+            string[] arr = str.Split(' ').TrimEnd();
             return Arrays.AsList(arr);
         }
 
@@ -277,12 +277,12 @@ namespace Lucene.Net.Analysis.Synonym
         [Obsolete("(3.0) does not support attributes api")]
         private IList<Token> Tokens(string str)
         {
-            string[] arr = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+            string[] arr = str.Split(' ').TrimEnd();
             IList<Token> result = new List<Token>();
             for (int i = 0; i < arr.Length; i++)
             {
-                string[] toks = arr[i].Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
-                string[] @params = toks[0].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
+                string[] toks = arr[i].Split('/').TrimEnd();
+                string[] @params = toks[0].Split(',').TrimEnd();
 
                 int posInc;
                 int start;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMapFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMapFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMapFilter.cs
index 30af766..ef09a42 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMapFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Synonym/TestSynonymMapFilter.cs
@@ -51,10 +51,10 @@ namespace Lucene.Net.Analysis.Synonym
             }
 
             CharsRef inputCharsRef = new CharsRef();
-            SynonymMap.Builder.Join(space.Split(input), inputCharsRef);
+            SynonymMap.Builder.Join(space.Split(input).TrimEnd(), inputCharsRef);
 
             CharsRef outputCharsRef = new CharsRef();
-            SynonymMap.Builder.Join(space.Split(output), outputCharsRef);
+            SynonymMap.Builder.Join(space.Split(output).TrimEnd(), outputCharsRef);
 
             b.Add(inputCharsRef, outputCharsRef, keepOrig);
         }
@@ -85,7 +85,7 @@ namespace Lucene.Net.Analysis.Synonym
 
             tokensIn.SetReader(new StringReader(input));
             tokensOut.Reset();
-            string[] expected = output.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+            string[] expected = output.Split(' ').TrimEnd();
             int expectedUpto = 0;
             while (tokensOut.IncrementToken())
             {
@@ -99,7 +99,7 @@ namespace Lucene.Net.Analysis.Synonym
                 int startOffset = offsetAtt.StartOffset;
                 int endOffset = offsetAtt.EndOffset;
 
-                string[] expectedAtPos = expected[expectedUpto++].Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
+                string[] expectedAtPos = expected[expectedUpto++].Split('/').TrimEnd();
                 for (int atPos = 0; atPos < expectedAtPos.Length; atPos++)
                 {
                     if (atPos > 0)
@@ -380,7 +380,7 @@ namespace Lucene.Net.Analysis.Synonym
                 }
                 foreach (string synOut in syn.@out)
                 {
-                    string[] synOutputs = synOut.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+                    string[] synOutputs = synOut.Split(' ').TrimEnd();
                     assertEquals(synOutputs.Length, (1 + synOut.Length) / 2);
                     int matchEnd = inputIDX + synOutputs.Length;
                     int synUpto = 0;
@@ -417,7 +417,7 @@ namespace Lucene.Net.Analysis.Synonym
             }
 
             StringBuilder sb = new StringBuilder();
-            string[] inputTokens = doc.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+            string[] inputTokens = doc.Split(' ').TrimEnd();
             int limit = inputTokens.Length + maxOutputLength;
             for (int inputIDX = 0; inputIDX < limit; inputIDX++)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharTokenizers.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharTokenizers.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharTokenizers.cs
index 87b8c22..37c7a04 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharTokenizers.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharTokenizers.cs
@@ -57,7 +57,7 @@ namespace Lucene.Net.Analysis.Util
             // internal buffer size is 1024 make sure we have a surrogate pair right at the border
             builder.Insert(1023, "\ud801\udc1c");
             var tokenizer = new LowerCaseTokenizer(TEST_VERSION_CURRENT, new StringReader(builder.ToString()));
-            AssertTokenStreamContents(tokenizer, builder.ToString().ToLowerInvariant().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
+            AssertTokenStreamContents(tokenizer, builder.ToString().ToLowerInvariant().Split(' ').TrimEnd());
         }
 
         /*

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizer.cs b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizer.cs
index 4331ce9..8e9bbfc 100644
--- a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizer.cs
+++ b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizer.cs
@@ -2,6 +2,7 @@
 using Lucene.Net.Analysis.Ja.TokenAttributes;
 using Lucene.Net.Analysis.TokenAttributes;
 using Lucene.Net.Attributes;
+using Lucene.Net.Support;
 using Lucene.Net.Util;
 using NUnit.Framework;
 using System;
@@ -797,7 +798,7 @@ namespace Lucene.Net.Analysis.Ja
                     IOUtils.DisposeWhileHandlingException(ts);
                 }
             }
-            String[] sentences = Regex.Split(line, "、|。");
+            String[] sentences = Regex.Split(line, "、|。").TrimEnd();
             if (VERBOSE)
             {
                 Console.WriteLine("Total time : " + (Environment.TickCount - totalStart));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Kuromoji/TestSearchMode.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestSearchMode.cs b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestSearchMode.cs
index f44feb0..f12b173 100644
--- a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestSearchMode.cs
+++ b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestSearchMode.cs
@@ -1,4 +1,5 @@
-using NUnit.Framework;
+using Lucene.Net.Support;
+using NUnit.Framework;
 using System;
 using System.IO;
 using System.Text;
@@ -63,9 +64,9 @@ namespace Lucene.Net.Analysis.Ja
                     {
                         Console.WriteLine("Line no. " + lineNumber + ": " + line);
                     }
-                    String[] fields = new Regex("\t").Split(line, 2); // Regex.Split(line, "\t", 2);
+                    String[] fields = new Regex("\t").Split(line, 2);
                     String sourceText = fields[0];
-                    String[] expectedTokens = Regex.Split(fields[1], "\\s+");
+                    String[] expectedTokens = Regex.Split(fields[1], "\\s+").TrimEnd();
                     int[] expectedPosIncrs = new int[expectedTokens.Length];
                     int[] expectedPosLengths = new int[expectedTokens.Length];
                     for (int tokIDX = 0; tokIDX < expectedTokens.Length; tokIDX++)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/BeiderMorseEncoderTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/BeiderMorseEncoderTest.cs b/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/BeiderMorseEncoderTest.cs
index 1d7fe8a..f85c95c 100644
--- a/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/BeiderMorseEncoderTest.cs
+++ b/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/BeiderMorseEncoderTest.cs
@@ -1,4 +1,5 @@
-using NUnit.Framework;
+using Lucene.Net.Support;
+using NUnit.Framework;
 using System;
 using System.Globalization;
 using System.Text;
@@ -168,7 +169,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
             String phonemes = encoder.Encode(phrase);
             Assert.True(phonemes.Length > 0);
 
-            String[] phonemeArr = new Regex("\\|").Split(phonemes);
+            String[] phonemeArr = new Regex("\\|").Split(phonemes).TrimEnd();
             Assert.True(phonemeArr.Length <= 10);
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/PhoneticEngineRegressionTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/PhoneticEngineRegressionTest.cs b/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/PhoneticEngineRegressionTest.cs
index cb9a40d..3f89405 100644
--- a/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/PhoneticEngineRegressionTest.cs
+++ b/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/PhoneticEngineRegressionTest.cs
@@ -209,7 +209,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
             }
             else
             {
-                languageSet = LanguageSet.From(new HashSet<String>(Arrays.AsList(languageSetArg.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))));
+                languageSet = LanguageSet.From(new HashSet<String>(Arrays.AsList(languageSetArg.Split(',').TrimEnd())));
             }
 
             /*

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/PhoneticEngineTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/PhoneticEngineTest.cs b/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/PhoneticEngineTest.cs
index 281fc45..25728b1 100644
--- a/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/PhoneticEngineTest.cs
+++ b/src/Lucene.Net.Tests.Analysis.Phonetic/Language/Bm/PhoneticEngineTest.cs
@@ -1,4 +1,5 @@
-using NUnit.Framework;
+using Lucene.Net.Support;
+using NUnit.Framework;
 using System;
 using System.Collections.Generic;
 using System.Text.RegularExpressions;
@@ -72,15 +73,15 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
 
             if (concat)
             {
-                String[] split = new Regex("\\|").Split(phoneticActual);
+                String[] split = new Regex("\\|").Split(phoneticActual).TrimEnd();
                 Assert.True(split.Length <= maxPhonemes);
             }
             else
             {
-                String[] words = phoneticActual.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
+                String[] words = phoneticActual.Split('-').TrimEnd();
                 foreach (String word in words)
                 {
-                    String[] split = new Regex("\\|").Split(word);
+                    String[] split = new Regex("\\|").Split(word).TrimEnd();
                     Assert.True(split.Length <= maxPhonemes);
                 }
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCompactLabelToOrdinal.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCompactLabelToOrdinal.cs b/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCompactLabelToOrdinal.cs
index 7066c5f..852638b 100644
--- a/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCompactLabelToOrdinal.cs
+++ b/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCompactLabelToOrdinal.cs
@@ -1,4 +1,5 @@
-using NUnit.Framework;
+using Lucene.Net.Support;
+using NUnit.Framework;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -94,7 +95,7 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
                 }
                 else
                 {
-                    label = new FacetLabel(s.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
+                    label = new FacetLabel(s.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries));
                 }
 
                 int ord1 = map.GetOrdinal(label);
@@ -125,7 +126,7 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
                 }
                 else
                 {
-                    label = new FacetLabel(s.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
+                    label = new FacetLabel(s.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries));
                 }
                 int ord1 = map.GetOrdinal(label);
                 int ord2 = compact.GetOrdinal(label);
@@ -210,7 +211,7 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
                     }
                     else
                     {
-                        label = new FacetLabel(s.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
+                        label = new FacetLabel(s.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries));
                     }
 
                     int ord1 = map.GetOrdinal(label);
@@ -242,7 +243,7 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
                 }
                 else
                 {
-                    label = new FacetLabel(s.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
+                    label = new FacetLabel(s.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries));
                 }
                 int ord1 = map.GetOrdinal(label);
                 int ord2 = compact.GetOrdinal(label);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.QueryParser/ComplexPhrase/TestComplexPhraseQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.QueryParser/ComplexPhrase/TestComplexPhraseQuery.cs b/src/Lucene.Net.Tests.QueryParser/ComplexPhrase/TestComplexPhraseQuery.cs
index fcdb4dd..fcb137e 100644
--- a/src/Lucene.Net.Tests.QueryParser/ComplexPhrase/TestComplexPhraseQuery.cs
+++ b/src/Lucene.Net.Tests.QueryParser/ComplexPhrase/TestComplexPhraseQuery.cs
@@ -3,6 +3,7 @@ using Lucene.Net.Documents;
 using Lucene.Net.Index;
 using Lucene.Net.Search;
 using Lucene.Net.Store;
+using Lucene.Net.Support;
 using Lucene.Net.Util;
 using NUnit.Framework;
 using System;
@@ -106,7 +107,7 @@ namespace Lucene.Net.QueryParsers.ComplexPhrase
             Query q = qp.Parse(qString);
 
             HashSet<string> expecteds = new HashSet<string>();
-            string[] vals = expectedVals.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
+            string[] vals = expectedVals.Split(',').TrimEnd();
             for (int i = 0; i < vals.Length; i++)
             {
                 if (vals[i].Length > 0)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery2.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery2.cs b/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery2.cs
index 525bf50..77173d3 100644
--- a/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery2.cs
+++ b/src/Lucene.Net.Tests.Sandbox/Queries/TestSlowFuzzyQuery2.cs
@@ -121,7 +121,7 @@ namespace Lucene.Net.Sandbox.Queries
             while ((line = reader.ReadLine()) != null)
             {
                 lineNum++;
-                String[] @params = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+                String[] @params = line.Split(',').TrimEnd();
                 String query = MapInt(codePointTable, int.Parse(@params[0], CultureInfo.InvariantCulture));
                 int prefix = int.Parse(@params[1], CultureInfo.InvariantCulture);
                 int pqSize = int.Parse(@params[2], CultureInfo.InvariantCulture);
@@ -135,7 +135,7 @@ namespace Lucene.Net.Sandbox.Queries
                 assertEquals(expectedResults, docs.TotalHits);
                 for (int i = 0; i < expectedResults; i++)
                 {
-                    String[] scoreDoc = reader.ReadLine().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+                    String[] scoreDoc = reader.ReadLine().Split(',').TrimEnd();
                     assertEquals(int.Parse(scoreDoc[0], CultureInfo.InvariantCulture), docs.ScoreDocs[i].Doc);
                     assertEquals(float.Parse(scoreDoc[1], CultureInfo.InvariantCulture), docs.ScoreDocs[i].Score, epsilon);
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Spatial/SpatialTestData.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Spatial/SpatialTestData.cs b/src/Lucene.Net.Tests.Spatial/SpatialTestData.cs
index d2be777..02461d6 100644
--- a/src/Lucene.Net.Tests.Spatial/SpatialTestData.cs
+++ b/src/Lucene.Net.Tests.Spatial/SpatialTestData.cs
@@ -1,4 +1,5 @@
-using Spatial4n.Core.Context;
+using Lucene.Net.Support;
+using Spatial4n.Core.Context;
 using Spatial4n.Core.Exceptions;
 using Spatial4n.Core.Shapes;
 using System;
@@ -52,7 +53,7 @@ namespace Lucene.Net.Spatial
                         continue;
 
                     SpatialTestData data = new SpatialTestData();
-                    String[] vals = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
+                    String[] vals = line.Split('\t').TrimEnd();
                     if (vals.Length != 3)
                         throw new Exception("bad format; expecting 3 tab-separated values for line: " + line);
                     data.id = vals[0];

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingInfixSuggesterTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingInfixSuggesterTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingInfixSuggesterTest.cs
index 5a9b35d..aeaf685 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingInfixSuggesterTest.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingInfixSuggesterTest.cs
@@ -751,7 +751,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
                         query += " ";
                     }
 
-                    string[] queryTerms = Regex.Split(query, "\\s", RegexOptions.Compiled);
+                    string[] queryTerms = Regex.Split(query, "\\s", RegexOptions.Compiled).TrimEnd();
                     bool allTermsRequired = Random().nextInt(10) == 7;
                     bool doHilite = Random().nextBoolean();
 
@@ -765,7 +765,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
                     for (int i = 0; i < visibleUpto; i++)
                     {
                         Input input = inputs.ElementAt(i);
-                        string[] inputTerms = Regex.Split(input.term.Utf8ToString(), "\\s", RegexOptions.Compiled);
+                        string[] inputTerms = Regex.Split(input.term.Utf8ToString(), "\\s", RegexOptions.Compiled).TrimEnd();
                         bool match = false;
                         for (int j = 0; j < queryTerms.Length; j++)
                         {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
index 5c5906f..3d75293 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
@@ -928,7 +928,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
                 List<TermFreq2> matches = new List<TermFreq2>();
 
                 // "Analyze" the key:
-                string[] tokens = prefix.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+                string[] tokens = prefix.Split(' ').TrimEnd();
                 StringBuilder builder = new StringBuilder();
                 bool lastRemoved = false;
                 for (int i = 0; i < tokens.Length; i++)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/FuzzySuggesterTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/FuzzySuggesterTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/FuzzySuggesterTest.cs
index cea67cb..29e73ca 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/FuzzySuggesterTest.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/FuzzySuggesterTest.cs
@@ -841,7 +841,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
                 List<Lookup.LookupResult> matches = new List<Lookup.LookupResult>();
 
                 // "Analyze" the key:
-                string[] tokens = prefix.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+                string[] tokens = prefix.Split(' ').TrimEnd();
                 StringBuilder builder = new StringBuilder();
                 bool lastRemoved = false;
                 for (int i = 0; i < tokens.Length; i++)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests/Analysis/TestGraphTokenizers.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Analysis/TestGraphTokenizers.cs b/src/Lucene.Net.Tests/Analysis/TestGraphTokenizers.cs
index b7f8adb..53bcbeb 100644
--- a/src/Lucene.Net.Tests/Analysis/TestGraphTokenizers.cs
+++ b/src/Lucene.Net.Tests/Analysis/TestGraphTokenizers.cs
@@ -136,7 +136,7 @@ namespace Lucene.Net.Analysis
 
                 InputLength = sb.Length;
 
-                string[] parts = sb.ToString().Split(' ');
+                string[] parts = sb.ToString().Split(' ').TrimEnd();
 
                 Tokens = new List<Token>();
                 int pos = 0;
@@ -145,7 +145,7 @@ namespace Lucene.Net.Analysis
                 //System.out.println("again");
                 foreach (string part in parts)
                 {
-                    string[] overlapped = part.Split('/');
+                    string[] overlapped = part.Split('/').TrimEnd();
                     bool firstAtPos = true;
                     int minPosLength = int.MaxValue;
                     foreach (string part2 in overlapped)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests/Index/TestDuelingCodecs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestDuelingCodecs.cs b/src/Lucene.Net.Tests/Index/TestDuelingCodecs.cs
index 6c2810b..06023cd 100644
--- a/src/Lucene.Net.Tests/Index/TestDuelingCodecs.cs
+++ b/src/Lucene.Net.Tests/Index/TestDuelingCodecs.cs
@@ -151,7 +151,7 @@ namespace Lucene.Net.Index
                 Document document = lineFileDocs.NextDoc();
                 // grab the title and add some SortedSet instances for fun
                 string title = document.Get("titleTokenized");
-                string[] split = whiteSpace.Split(title);
+                string[] split = whiteSpace.Split(title).TrimEnd();
                 foreach (string trash in split)
                 {
                     document.Add(new SortedSetDocValuesField("sortedset", new BytesRef(trash)));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests/Index/TestIndexWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs
index 21fafd1..8010e70 100644
--- a/src/Lucene.Net.Tests/Index/TestIndexWriter.cs
+++ b/src/Lucene.Net.Tests/Index/TestIndexWriter.cs
@@ -1998,7 +1998,7 @@ namespace Lucene.Net.Index
                 {
                     b.Append(buffer, 0, n);
                 }
-                this.Tokens = b.ToString().Split(' ');
+                this.Tokens = b.ToString().Split(' ').TrimEnd();
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests/Search/Payloads/TestPayloadNearQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Search/Payloads/TestPayloadNearQuery.cs b/src/Lucene.Net.Tests/Search/Payloads/TestPayloadNearQuery.cs
index c608df2..261ac15 100644
--- a/src/Lucene.Net.Tests/Search/Payloads/TestPayloadNearQuery.cs
+++ b/src/Lucene.Net.Tests/Search/Payloads/TestPayloadNearQuery.cs
@@ -103,7 +103,7 @@ namespace Lucene.Net.Search.Payloads
 
         private PayloadNearQuery NewPhraseQuery(string fieldName, string phrase, bool inOrder, PayloadFunction function)
         {
-            var words = _whiteSpaceRegex.Split(phrase);
+            var words = _whiteSpaceRegex.Split(phrase).TrimEnd();
             var clauses = new SpanQuery[words.Length];
             for (var i = 0; i < clauses.Length; i++)
             {
@@ -301,7 +301,7 @@ namespace Lucene.Net.Search.Payloads
 
         private SpanNearQuery SpanNearQuery(string fieldName, string words)
         {
-            var wordList = _whiteSpaceRegex.Split(words);
+            var wordList = _whiteSpaceRegex.Split(words).TrimEnd();
             var clauses = new SpanQuery[wordList.Length];
             for (var i = 0; i < clauses.Length; i++)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests/Search/TestSloppyPhraseQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Search/TestSloppyPhraseQuery.cs b/src/Lucene.Net.Tests/Search/TestSloppyPhraseQuery.cs
index 5c010ac..2c59335 100644
--- a/src/Lucene.Net.Tests/Search/TestSloppyPhraseQuery.cs
+++ b/src/Lucene.Net.Tests/Search/TestSloppyPhraseQuery.cs
@@ -1,9 +1,11 @@
-using System;
 using Lucene.Net.Documents;
+using Lucene.Net.Support;
+using NUnit.Framework;
+using System;
+using System.Text.RegularExpressions;
 
 namespace Lucene.Net.Search
 {
-    using NUnit.Framework;
     using AtomicReaderContext = Lucene.Net.Index.AtomicReaderContext;
     using Directory = Lucene.Net.Store.Directory;
     using Document = Documents.Document;
@@ -38,6 +40,8 @@ namespace Lucene.Net.Search
     [TestFixture]
     public class TestSloppyPhraseQuery : LuceneTestCase
     {
+        private static Regex SPACES = new Regex(" +", RegexOptions.Compiled);
+
         private const string S_1 = "A A A";
         private const string S_2 = "A 1 2 3 A 4 5 6 A";
 
@@ -194,10 +198,12 @@ namespace Lucene.Net.Search
             return doc;
         }
 
+        
+
         private static PhraseQuery MakePhraseQuery(string terms)
         {
             PhraseQuery query = new PhraseQuery();
-            string[] t = terms.Split(" +".ToCharArray());
+            string[] t = SPACES.Split(terms).TrimEnd();
             for (int i = 0; i < t.Length; i++)
             {
                 query.Add(new Term("f", t[i]));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net.Tests/Search/TestTimeLimitingCollector.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Search/TestTimeLimitingCollector.cs b/src/Lucene.Net.Tests/Search/TestTimeLimitingCollector.cs
index 4e258d2..c3ad145 100644
--- a/src/Lucene.Net.Tests/Search/TestTimeLimitingCollector.cs
+++ b/src/Lucene.Net.Tests/Search/TestTimeLimitingCollector.cs
@@ -58,6 +58,8 @@ namespace Lucene.Net.Search
         private Counter counter;
         private TimeLimitingCollector.TimerThread counterThread;
 
+        private readonly static Regex WHITESPACE = new Regex("\\s+", RegexOptions.Compiled);
+
         /**
          * initializes searcher with a document set
          */
@@ -93,7 +95,7 @@ namespace Lucene.Net.Search
             // start from 1, so that the 0th doc never matches
             for (int i = 1; i < docText.Length; i++)
             {
-                string[] docTextParts = Regex.Split(docText[i], "\\s+");
+                string[] docTextParts = WHITESPACE.Split(docText[i]).TrimEnd();
                 foreach (string docTextPart in docTextParts)
                 {
                     // large query so that search will be longer

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a57d9f11/src/Lucene.Net/Support/StringExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/StringExtensions.cs b/src/Lucene.Net/Support/StringExtensions.cs
index 0bb596b..c051a60 100644
--- a/src/Lucene.Net/Support/StringExtensions.cs
+++ b/src/Lucene.Net/Support/StringExtensions.cs
@@ -138,10 +138,6 @@ namespace Lucene.Net.Support
             return -1;
         }
 
-        // LUCENENET TODO: BUG Replace all calls to .Split("", StringSplitOptions.RemoveEmptyEntries)
-        // and Regex.Split("") with .Split("").TrimEnd() and Regex.Split("").TrimEnd() to match the 
-        // behavior of Java's Split() method.
-
         /// <summary>
         /// Removes null or empty elements from the end of a string array.
         /// </summary>


Mime
View raw message