Skip to content

Commit 39cebfb

Browse files
committed
adding javadoc
1 parent b476ecf commit 39cebfb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/main/java/ru/lanwen/verbalregex/VerbalExpression.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.regex.Pattern;
55

66
import static java.lang.String.valueOf;
7+
import static ru.lanwen.verbalregex.VerbalExpression.regex;
78

89
public class VerbalExpression {
910

@@ -171,6 +172,24 @@ public Builder maybe(final String pValue) {
171172
return this.then(pValue).add("?");
172173
}
173174

175+
/**
176+
* Add a regex to the expression that might appear once (or not)
177+
* Example:
178+
* The following matches all names that have a prefix or not.
179+
* VerbalExpression.Builder namePrefix = regex().oneOf("Mr.", "Ms.");
180+
* VerbalExpression name = regex()
181+
* .maybe(namePrefix)
182+
* .space()
183+
* .zeroOrMore()
184+
* .word()
185+
* .oneOrMore()
186+
* .build();
187+
* regex.test("Mr. Bond/") //true
188+
* regex.test("James") //true
189+
*
190+
* @param pValue - the string to be looked for
191+
* @return this builder
192+
*/
174193
public Builder maybe(final Builder regex) {
175194
return this.group().add(regex.build().toString()).endGr().add("?");
176195
}

0 commit comments

Comments
 (0)