Package snap.parse
Class Regex
java.lang.Object
snap.parse.Regex
A class for building regular expressions like a string buffer.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds any char (doesn't include newlines).addChar
(char c) Adds a literal char.void
Adds a letter.addDigit()
Adds a digit: [0-9].void
Adds 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].char
Returns the first literal in regex pattern (or 0 if not literal).static char
getLiteralChar
(String aPattern) Returns the first char of a pattern, if it's a literal char.int
Returns the literal length of this regex (the number of literal chars in the prefix).static int
getLiteralLength
(String aPattern) Returns the literal length of pattern.Returns the shared matcher.getName()
Returns the regex name.Returns the regex pattern.Returns the compiled pattern.int
Returns pattern compile flags.static boolean
isAncharChar
(char c) Utility method to return whether char is an anchor char.boolean
Returns whether pattern is literal.static boolean
isSpecialChar
(char c) Utility method to return whether given character is a special char.void
Sets the regex name.void
setPattern
(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
Constructor 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. -
getPatternCompiled
Returns the compiled pattern. -
getPatternCompileFlags
public int getPatternCompileFlags()Returns pattern compile flags. -
getMatcher
Returns the shared matcher. -
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.
-