Class Regex
java.lang.Object
com.inductiveautomation.snap.parse.Regex
A class for building regular expressions like a string buffer.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds any char (doesn't include newlines).addChar(char c) Adds a literal char.voidAdds a letter.addDigit()Adds a digit: [0-9].voidAdds a group.Adds any letter.Adds any letter.Adds any letter.Adds a non-digit: [^0-9].Adds non-whitespace char: [^\s].Adds a non-word character: [^\w].Adds whitespace char [ \t\n\x0B\f\r].Adds a word character: [a-zA-Z_0-9].charReturns the first literal in regex pattern (or 0 if not literal).static chargetLiteralChar(String aPattern) Returns the first char of a pattern, if it's a literal char.intReturns the literal length of this regex (the number of literal chars in the prefix).static intgetLiteralLength(String aPattern) Returns the literal length of pattern.getMatcher(CharSequence anInput) Returns the shared matcher (initialized to the given char sequence if not yet created).getName()Returns the regex name.Returns the regex pattern.Returns the compiled pattern.intReturns pattern compile flags.static booleanisAncharChar(char c) Utility method to return whether char is an anchor char.booleanReturns 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.voidSets the regex name.voidsetPattern(String aPattern) Sets the pattern.toString()Returns a string representation of regex.
-
Field Details
-
LetterLower
- See Also:
-
LetterUpper
- See Also:
-
Digit
- See Also:
-
WhiteSpace
- See Also:
-
-
Constructor Details
-
Regex
public Regex()Creates a new regex. -
Regex
Creates a new regex with given pattern and name. -
Regex
Creates a new regex with given pattern and name.
-
-
Method Details
-
getName
Returns the regex name. -
setName
Sets the regex name. -
getPattern
Returns the regex pattern. -
setPattern
Sets the pattern. -
isLiteral
public boolean isLiteral()Returns whether pattern is literal. -
setLiteral
public void setLiteral(boolean aFlag) Sets whether pattern is literal. -
getPatternCompiled
Returns the compiled pattern. -
getPatternCompileFlags
public int getPatternCompileFlags()Returns pattern compile flags. -
getMatcher
Returns the shared matcher (initialized to the given char sequence if not yet created). -
getLiteralLength
public int getLiteralLength()Returns the literal length of this regex (the number of literal chars in the prefix). -
getLiteralChar
public char getLiteralChar()Returns the first literal in regex pattern (or 0 if not literal). -
addGroup
Adds a group. -
addChars
Adds a letter. -
addChar
Adds a literal char. -
addLetter
Adds any letter. -
addLetterLower
Adds any letter. -
addLetterUpper
Adds any letter. -
addAnyChar
Adds any char (doesn't include newlines). -
addDigit
Adds a digit: [0-9]. -
addNonDigit
Adds a non-digit: [^0-9]. -
addWhitespace
Adds whitespace char [ \t\n\x0B\f\r]. -
addNonWhitespace
Adds non-whitespace char: [^\s]. -
addWordCharacter
Adds a word character: [a-zA-Z_0-9]. -
addNonWordCharacter
Adds a non-word character: [^\w]. -
toString
Returns a string representation of regex. -
isSpecialChar
public static boolean isSpecialChar(char c) Utility method to return whether given character is a special char. -
isAncharChar
public static boolean isAncharChar(char c) Utility method to return whether char is an anchor char. -
getLiteralLength
Returns the literal length of pattern. -
getLiteralChar
Returns the first char of a pattern, if it's a literal char.
-