public class RegExpGenerator
extends java.lang.Object
Typical usage is:
RegExpGenerator generator = new RegExpGenerator();
generator.train("janv.");
generator.train("oct");
generator.train("dec.");
...
String result = generator.getResult();
Constructor and Description |
---|
RegExpGenerator() |
RegExpGenerator(boolean asSet,
int maxSetSize,
java.util.Locale locale) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getResult()
Given the set of Strings trained() return a Regular Expression which will accept any of the training set.
|
java.util.Set<java.lang.String> |
getValues()
Get the set of Strings (in upper case) used to train the Generator.
|
static boolean |
isSpecial(char ch)
Is the supplied character reserved a special meaning in Regular Expressions?
Note: We do not declare '-' as a special character, so should not be used in a Character Class
|
static java.lang.String |
merge(java.lang.String firstRE,
java.lang.String secondRE) |
static java.lang.String |
slosh(char ch) |
static java.lang.String |
slosh(java.lang.String input)
Return an escaped String (similar to Pattern.quote but not unconditional).
|
static java.lang.String |
smash(java.lang.String input)
Fast method to simplify a string so that we can determine if all inputs are of the same form.
|
static java.lang.String |
smashedAsRegExp(java.lang.String smashed)
Generate a Regular Expression from the 'smashed' input.
|
void |
train(java.lang.String input)
This method should be called for each string in the set.
|
public RegExpGenerator()
public RegExpGenerator(boolean asSet, int maxSetSize, java.util.Locale locale)
public static boolean isSpecial(char ch)
ch
- The character to test.public static java.lang.String slosh(char ch)
public static java.lang.String merge(java.lang.String firstRE, java.lang.String secondRE)
public static java.lang.String slosh(java.lang.String input)
input
- The String to be protected.public static java.lang.String smash(java.lang.String input)
input
- The input String to be smashed.public static java.lang.String smashedAsRegExp(java.lang.String smashed)
smashed
- The smashed inputpublic void train(java.lang.String input)
input
- The String to be used as part of the set.public java.lang.String getResult()
public java.util.Set<java.lang.String> getValues()