diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-14 14:47:07 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-14 14:47:07 -0400 |
| commit | e106e1f36fb04adc14f9c8a30587bf349bdcaf54 (patch) | |
| tree | 7600e478a9e4e65e81e33ff228052367cf3cc84b /BJC-Utils2/src/main/java | |
| parent | 3086c3ec5019e8a3c74366d057518c7dbd4aea6e (diff) | |
Added ability to ignore strings to splitter
Diffstat (limited to 'BJC-Utils2/src/main/java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/funcutils/NeoTokenSplitter.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/NeoTokenSplitter.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/NeoTokenSplitter.java index 6007429..25b1e03 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/NeoTokenSplitter.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/NeoTokenSplitter.java @@ -59,9 +59,10 @@ public class NeoTokenSplitter { if(compPatt == null) throw new IllegalStateException("Token splitter has not been compiled yet"); /* - * Don't split something that matches only an operator + * Don't split something that we should exclude from being split. */ if(exclusionPatt.matcher(inp).matches()) return new String[] { inp }; + return compPatt.split(inp); } @@ -117,6 +118,23 @@ public class NeoTokenSplitter { } /** + * Marks strings matching the pattern delim as non-splittable. + * + * @param delim + * The regex to not splitting matching strings. + */ + public void addNonMatcher(String delim) { + if(currPatt == null) { + currPatt = new StringBuilder(); + currExclusionPatt = new StringBuilder(); + + currExclusionPatt.append("(?:" + delim + ")"); + } else { + currExclusionPatt.append("|(?:" + delim + ")"); + } + } + + /** * Compiles the current set of delimiters to a pattern. * * Makes this splitter ready to use. |
