@@ -218,6 +218,102 @@ public RegexBuilder nonWhitespace(final RegexQuantifier quantifier) {
218218 return this ;
219219 }
220220
221+ /**
222+ * Add an element to represent any amount of white space, including none. This is just a convenient alias for
223+ * {@code whitespace(RegexQuantifier.zeroOrMore())}.
224+ *
225+ * @return The current {@link RegexBuilder} object, for method chaining
226+ */
227+ public RegexBuilder possibleWhitespace () {
228+ return whitespace (RegexQuantifier .zeroOrMore ());
229+ }
230+
231+ /**
232+ * Add an element to match a single space character. If you want to match any kind of white space, use
233+ * {@link #whitespace()}.
234+ *
235+ * @return The current {@link RegexBuilder} object, for method chaining
236+ */
237+ public RegexBuilder space () {
238+ return space (null );
239+ }
240+
241+ /**
242+ * Add an element to match a single space character. If you want to match any kind of white space, use
243+ * {@link #whitespace()}.
244+ *
245+ * @param quantifier Quantifier to apply to this element
246+ * @return The current {@link RegexBuilder} object, for method chaining
247+ */
248+ public RegexBuilder space (final RegexQuantifier quantifier ) {
249+ stringBuilder .append (" " );
250+ addQuantifier (quantifier );
251+ return this ;
252+ }
253+
254+ /**
255+ * Add an element to match a single tab character.
256+ *
257+ * @return The current {@link RegexBuilder} object, for method chaining
258+ */
259+ public RegexBuilder tab () {
260+ return tab (null );
261+ }
262+
263+ /**
264+ * Add an element to match a single tab character.
265+ *
266+ * @param quantifier Quantifier to apply to this element
267+ * @return The current {@link RegexBuilder} object, for method chaining
268+ */
269+ public RegexBuilder tab (final RegexQuantifier quantifier ) {
270+ stringBuilder .append ("\\ t" );
271+ addQuantifier (quantifier );
272+ return this ;
273+ }
274+
275+ /**
276+ * Add an element to match a single line feed character.
277+ *
278+ * @return The current {@link RegexBuilder} object, for method chaining
279+ */
280+ public RegexBuilder lineFeed () {
281+ return lineFeed (null );
282+ }
283+
284+ /**
285+ * Add an element to match a single line feed character.
286+ *
287+ * @param quantifier Quantifier to apply to this element
288+ * @return The current {@link RegexBuilder} object, for method chaining
289+ */
290+ public RegexBuilder lineFeed (final RegexQuantifier quantifier ) {
291+ stringBuilder .append ("\\ n" );
292+ addQuantifier (quantifier );
293+ return this ;
294+ }
295+
296+ /**
297+ * Add an element to match a single carriage return character.
298+ *
299+ * @return The current {@link RegexBuilder} object, for method chaining
300+ */
301+ public RegexBuilder carriageReturn () {
302+ return carriageReturn (null );
303+ }
304+
305+ /**
306+ * Add an element to match a single carriage return character.
307+ *
308+ * @param quantifier Quantifier to apply to this element
309+ * @return The current {@link RegexBuilder} object, for method chaining
310+ */
311+ public RegexBuilder carriageReturn (final RegexQuantifier quantifier ) {
312+ stringBuilder .append ("\\ r" );
313+ addQuantifier (quantifier );
314+ return this ;
315+ }
316+
221317 /**
222318 * Add an element to match any single decimal digit (0-9).
223319 *
@@ -574,7 +670,7 @@ public RegexBuilder anyCharacterExcept(final String characters, final RegexQuant
574670 * @param strings A number of strings, any one of which will be matched
575671 * @return The current {@link RegexBuilder} object, for method chaining
576672 */
577- public RegexBuilder anyOf (final String [] strings ) {
673+ public RegexBuilder anyOf (final String ... strings ) {
578674 return anyOf (strings , null );
579675 }
580676
@@ -604,7 +700,7 @@ public RegexBuilder anyOf(final String[] strings, final RegexQuantifier quantifi
604700 RegexBuilder builder = null ;
605701 try {
606702 builder = startNonCapturingGroup ()
607- .regexText (String .join ("|" , safeStrings ), quantifier )
703+ .regexText (String .join ("|" , safeStrings ))
608704 .endGroup (quantifier );
609705 } catch (RegexBuilderException ignored ) {
610706 // We won't get an exception from endGroup() as we know we started the group properly
@@ -760,8 +856,7 @@ private String makeSafeForCharacterClass(final String s) {
760856 }
761857
762858 private static String makeSafeForRegex (final String s ) {
763-
764- return s
859+ return (s == null ) ? "" : s
765860 // Make sure this always comes first!
766861 .replace ("\\ " , "\\ \\ " )
767862 .replace ("?" , "\\ ?" )
0 commit comments