org.tbull.util
Class Grepper.RegexGrepper
Object
org.tbull.util.Grepper.RegexGrepper
- All Implemented Interfaces:
- Grepper<CharSequence>
- Enclosing interface:
- Grepper<E>
public static class Grepper.RegexGrepper
- extends Object
- implements Grepper<CharSequence>
A Grepper
that matches string-like elements against a regular expression.
List<String> integer_strings = grep(new Grepper.RegexGrepper("[0-9]+"), strings);
- ToDo:
- This grepper has not yet been tested.
Grepper.RegexGrepper
public Grepper.RegexGrepper(String regex)
throws PatternSyntaxException
- Constructs a
RegexGrepper
from a given regular expression.
- Throws:
PatternSyntaxException
Grepper.RegexGrepper
public Grepper.RegexGrepper(Pattern pattern)
- Constructs a
RegexGrepper
from a precompiled Pattern
.
grep
public boolean grep(CharSequence element)
- Greps elements that match the regular expression as per
Matcher.matches()
.
- Specified by:
grep
in interface Grepper<CharSequence>
- Parameters:
element
- The element under test.
- Returns:
true
if the element matches the grep condition, thus should be added to the results,
otherwise false
.