Append literal expression
Everything added to the expression should go trough this method
(keep in mind when creating your own methods).
Append a regex from builder and wrap it with unnamed group (?: ...
Add expression that matches anything (includes empty string)
Add expression that matches anything, but not passed argument
VerbalExpression.Builder.atLeast(int from)
Produce range count with only minimal number of occurrences
for example:
.find("w").atLeast(1) // produce (?:w){1,}
VerbalExpression.Builder.br()
VerbalExpression.Builder.capt()
Adds capture - open brace to current position and closed to suffixes
Adds named-capture - open brace to current position and closed to suffixes
VerbalExpression.Builder.count(int count)
Add count of previous group
for example:
.find("w").count(3) // produce - (?:w){3}
VerbalExpression.Builder.count(int from,
int to)
Produce range count
for example:
.find("w").count(1, 3) // produce (?:w){1,3}
VerbalExpression.Builder.digit()
Close brace for previous capture and remove last closed brace from suffixes
Can be used to continue build regex after capture or to add multiply captures
VerbalExpression.Builder.endGr()
VerbalExpression.Builder.endOfLine(boolean pEnable)
Enable or disable the expression to end at the last character of the line
VerbalExpression.Builder.group()
Same as
VerbalExpression.Builder.capture(), but don't save result
May be used to set count of duplicated captures, without creating a new saved capture
Example:
// Without group() - count(2) applies only to second capture
regex().group()
.capt().range("0", "1").endCapt().tab()
.capt().digit().count(5).endCapt()
.endGr().count(2);
Add universal line break expression
Add a string to the expression that might appear once (or not)
Example:
The following matches all strings that contain http:// or https://
VerbalExpression regex = regex()
.find("http")
.maybe("s")
.then("://")
.anythingBut(" ").build();
regex.test("http://") //true
regex.test("https://") //true
Add a regex to the expression that might appear once (or not)
Example:
The following matches all names that have a prefix or not.
Convenient method to show that string usage count is exact count, range count or simply one or more
Usage:
regex().multiply("abc") // Produce (?:abc)+
regex().multiply("abc", null) // Produce (?:abc)+
regex().multiply("abc", (int)from) // Produce (?:abc){from}
regex().multiply("abc", (int)from, (int)to) // Produce (?:abc){from, to}
regex().multiply("abc", (int)from, (int)to, (int)...) // Produce (?:abc)+
Add non-whitespace character: [^\s]
Add non-word character: [^\w]
Adds an alternative expression to be matched
based on an array of values
VerbalExpression.Builder.or(String pValue)
Add a alternative expression to be matched
Issue #32
Add expression to match a range (or multiply ranges)
Usage: .range(from, to [, from, to ...
Creates new instance of VerbalExpression builder
Creates new instance of VerbalExpression builder from cloned builder
Add expression that matches something that might appear once (or more)
VerbalExpression.Builder.space()
Add whitespace character, same as [ \t\n\x0B\f\r]
Enable or disable the expression to start at the beginning of the line
VerbalExpression.Builder.tab()
Add expression to match a tab character (' ')
Add a string to the expression
Turn ON matching with ignoring case
Example:
// matches "a"
// matches "A"
regex().find("a").withAnyCase()
VerbalExpression.Builder.word()
Add word, same as [a-zA-Z_0-9]+
Add word character, same as [a-zA-Z_0-9]