Class Regex
- java.lang.Object
- 
- com.inductiveautomation.snap.parse.Regex
 
- 
 public class Regex extends java.lang.ObjectA class for building regular expressions like a string buffer.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classRegex.Op
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringDigitstatic java.lang.StringLetterLowerstatic java.lang.StringLetterUpperstatic java.lang.StringWhiteSpace
 - 
Constructor SummaryConstructors Constructor Description Regex()Creates a new regex.Regex(java.lang.String aName, java.lang.String aPattern)Creates a new regex with given pattern and name.Regex(java.lang.String aName, java.lang.String aPattern, boolean isLiteral)Creates a new regex with given pattern and name.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RegexaddAnyChar()Adds any char (doesn't include newlines).RegexaddChar(char c)Adds a literal char.voidaddChars(java.lang.String... theParts)Adds a letter.RegexaddDigit()Adds a digit: [0-9].voidaddGroup(Regex.Op anOp, java.lang.String... theParts)Adds a group.RegexaddLetter()Adds any letter.RegexaddLetterLower()Adds any letter.RegexaddLetterUpper()Adds any letter.RegexaddNonDigit()Adds a non-digit: [^0-9].RegexaddNonWhitespace()Adds non-whitespace char: [^\s].RegexaddNonWordCharacter()Adds a non-word character: [^\w].RegexaddWhitespace()Adds whitespace char [ \t\n\x0B\f\r].RegexaddWordCharacter()Adds a word character: [a-zA-Z_0-9].chargetLiteralChar()Returns the first literal in regex pattern (or 0 if not literal).static chargetLiteralChar(java.lang.String aPattern)Returns the first char of a pattern, if it's a literal char.intgetLiteralLength()Returns the literal length of this regex (the number of literal chars in the prefix).static intgetLiteralLength(java.lang.String aPattern)Returns the literal length of pattern.java.util.regex.MatchergetMatcher(java.lang.CharSequence anInput)Returns the shared matcher (initialized to the given char sequence if not yet created).java.lang.StringgetName()Returns the regex name.java.lang.StringgetPattern()Returns the regex pattern.java.util.regex.PatterngetPatternCompiled()Returns the compiled pattern.intgetPatternCompileFlags()Returns pattern compile flags.static booleanisAncharChar(char c)Utility method to return whether char is an anchor char.booleanisLiteral()Returns whether pattern is literal.static booleanisSpecialChar(char c)Utility method to return whether given character is a special char.voidsetLiteral(boolean aFlag)Sets whether pattern is literal.voidsetName(java.lang.String aName)Sets the regex name.voidsetPattern(java.lang.String aPattern)Sets the pattern.java.lang.StringtoString()Returns a string representation of regex.
 
- 
- 
- 
Field Detail- 
LetterLowerpublic static final java.lang.String LetterLower - See Also:
- Constant Field Values
 
 - 
LetterUpperpublic static final java.lang.String LetterUpper - See Also:
- Constant Field Values
 
 - 
Digitpublic static final java.lang.String Digit - See Also:
- Constant Field Values
 
 - 
WhiteSpacepublic static final java.lang.String WhiteSpace - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
Regexpublic Regex() Creates a new regex.
 - 
Regexpublic Regex(java.lang.String aName, java.lang.String aPattern)Creates a new regex with given pattern and name.
 - 
Regexpublic Regex(java.lang.String aName, java.lang.String aPattern, boolean isLiteral)Creates a new regex with given pattern and name.
 
- 
 - 
Method Detail- 
getNamepublic java.lang.String getName() Returns the regex name.
 - 
setNamepublic void setName(java.lang.String aName) Sets the regex name.
 - 
getPatternpublic java.lang.String getPattern() Returns the regex pattern.
 - 
setPatternpublic void setPattern(java.lang.String aPattern) Sets the pattern.
 - 
isLiteralpublic boolean isLiteral() Returns whether pattern is literal.
 - 
setLiteralpublic void setLiteral(boolean aFlag) Sets whether pattern is literal.
 - 
getPatternCompiledpublic java.util.regex.Pattern getPatternCompiled() Returns the compiled pattern.
 - 
getPatternCompileFlagspublic int getPatternCompileFlags() Returns pattern compile flags.
 - 
getMatcherpublic java.util.regex.Matcher getMatcher(java.lang.CharSequence anInput) Returns the shared matcher (initialized to the given char sequence if not yet created).
 - 
getLiteralLengthpublic int getLiteralLength() Returns the literal length of this regex (the number of literal chars in the prefix).
 - 
getLiteralCharpublic char getLiteralChar() Returns the first literal in regex pattern (or 0 if not literal).
 - 
addGrouppublic void addGroup(Regex.Op anOp, java.lang.String... theParts) Adds a group.
 - 
addCharspublic void addChars(java.lang.String... theParts) Adds a letter.
 - 
addCharpublic Regex addChar(char c) Adds a literal char.
 - 
addLetterpublic Regex addLetter() Adds any letter.
 - 
addLetterLowerpublic Regex addLetterLower() Adds any letter.
 - 
addLetterUpperpublic Regex addLetterUpper() Adds any letter.
 - 
addAnyCharpublic Regex addAnyChar() Adds any char (doesn't include newlines).
 - 
addDigitpublic Regex addDigit() Adds a digit: [0-9].
 - 
addNonDigitpublic Regex addNonDigit() Adds a non-digit: [^0-9].
 - 
addWhitespacepublic Regex addWhitespace() Adds whitespace char [ \t\n\x0B\f\r].
 - 
addNonWhitespacepublic Regex addNonWhitespace() Adds non-whitespace char: [^\s].
 - 
addWordCharacterpublic Regex addWordCharacter() Adds a word character: [a-zA-Z_0-9].
 - 
addNonWordCharacterpublic Regex addNonWordCharacter() Adds a non-word character: [^\w].
 - 
toStringpublic java.lang.String toString() Returns a string representation of regex.- Overrides:
- toStringin class- java.lang.Object
 
 - 
isSpecialCharpublic static boolean isSpecialChar(char c) Utility method to return whether given character is a special char.
 - 
isAncharCharpublic static boolean isAncharChar(char c) Utility method to return whether char is an anchor char.
 - 
getLiteralLengthpublic static int getLiteralLength(java.lang.String aPattern) Returns the literal length of pattern.
 - 
getLiteralCharpublic static char getLiteralChar(java.lang.String aPattern) Returns the first char of a pattern, if it's a literal char.
 
- 
 
-