Class VerbalExpression
java.lang.Object
ru.lanwen.verbalregex.VerbalExpression
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateVerbalExpression(Pattern pattern) Use builderregex()(orregex(ru.lanwen.verbalregex.VerbalExpression.Builder)) to create new instance of VerbalExpression -
Method Summary
Modifier and TypeMethodDescriptionExtract full string that matches regex Same asgetText(String, int)for 0 groupExtract exact group from stringExtract exact named-group from stringgetTextGroups(String toTest, int group) Extract exact group from string and add it to list Example: String text = "SampleHelloWorldString"; VerbalExpression regex = regex().capt().oneOf("Hello", "World").endCapt().maybe("String").build(); list = regex.getTextGroups(text, 0) //result: "Hello", "WorldString" list = regex.getTextGroups(text, 1) //result: "Hello", "World"static VerbalExpression.Builderregex()Creates new instance of VerbalExpression builderstatic VerbalExpression.Builderregex(VerbalExpression.Builder pBuilder) Creates new instance of VerbalExpression builder from cloned builderbooleanTest that full string contains regexbooleanTest that full string matches regular expressiontoString()
-
Field Details
-
pattern
-
-
Constructor Details
-
VerbalExpression
Use builderregex()(orregex(ru.lanwen.verbalregex.VerbalExpression.Builder)) to create new instance of VerbalExpression- Parameters:
pattern- -Patternthat constructed by builder
-
-
Method Details
-
testExact
Test that full string matches regular expression- Parameters:
pToTest- - string to check match- Returns:
- true if matches exact string, false otherwise
-
test
Test that full string contains regex- Parameters:
pToTest- - string to check match- Returns:
- true if string contains regex, false otherwise
-
getText
Extract full string that matches regex Same asgetText(String, int)for 0 group- Parameters:
toTest- - string to extract from- Returns:
- group 0, extracted from text
-
getText
-
getText
Extract exact named-group from stringExample is see to
VerbalExpression.Builder.capture(String)- Parameters:
toTest- - string to extract fromgroup- - group to extract- Returns:
- extracted group
- Since:
- 1.6
-
getTextGroups
Extract exact group from string and add it to list Example: String text = "SampleHelloWorldString"; VerbalExpression regex = regex().capt().oneOf("Hello", "World").endCapt().maybe("String").build(); list = regex.getTextGroups(text, 0) //result: "Hello", "WorldString" list = regex.getTextGroups(text, 1) //result: "Hello", "World"- Parameters:
toTest- - string to extract fromgroup- - group to extract- Returns:
- list of extracted groups
-
toString
-
regex
Creates new instance of VerbalExpression builder from cloned builder- Parameters:
pBuilder- - instance to clone- Returns:
- new VerbalExpression.Builder copied from passed
- Since:
- 1.1
-
regex
Creates new instance of VerbalExpression builder- Returns:
- new VerbalExpression.Builder
- Since:
- 1.1
-