Class RegularExpression<E>
java.lang.Object
edu.washington.cs.knowitall.regex.RegularExpression<E>
- Type Parameters:
E
- the type of the sequence elements
public class RegularExpression<E>
extends Object
implements com.google.common.base.Predicate<List<E>>
A regular expression engine that operates over sequences of user-specified
objects.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Apply the expression against a list of tokens.static <E> FiniteAutomaton.Automaton<E>
build
(List<Expression<E>> exprs) Build an NFA from the list of expressions.static <E> RegularExpression<E>
compile
(String expression, com.google.common.base.Function<String, Expression.BaseExpression<E>> factoryDelegate) Create a regular expression from the specified string.static <E> RegularExpression<E>
compile
(List<Expression<E>> expressions) Create a regular expression without tokenization support.boolean
Find the first match of the regular expression against tokens.Find the first match of the regular expression against tokens, starting at the specified index.Find all non-overlapping matches of the regular expression against tokens.int
hashCode()
Determine if the regular expression matches the beginning of the supplied tokens.Determine if the regular expression matches the supplied tokens, starting at the specified index.static void
An interactive program that compiles a word-based regular expression specified in arg1 and then reads strings from stdin, evaluating them against the regular expression.boolean
Apply the expression against a list of tokens.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.common.base.Predicate
test
-
Field Details
-
expressions
-
auto
-
-
Constructor Details
-
RegularExpression
-
-
Method Details
-
compile
Create a regular expression without tokenization support.- Parameters:
expressions
-- Returns:
-
compile
public static <E> RegularExpression<E> compile(String expression, com.google.common.base.Function<String, Expression.BaseExpression<E>> factoryDelegate) Create a regular expression from the specified string.- Parameters:
expression
-factoryDelegate
-- Returns:
-
equals
-
hashCode
public int hashCode() -
toString
-
build
Build an NFA from the list of expressions.- Parameters:
exprs
-- Returns:
-
apply
Apply the expression against a list of tokens.- Specified by:
apply
in interfacecom.google.common.base.Predicate<E>
- Returns:
- true iff the expression if found within the tokens.
-
matches
Apply the expression against a list of tokens.- Returns:
- true iff the expression matches all of the tokens.
-
find
Find the first match of the regular expression against tokens. This method is slightly slower due to additional memory allocations. However, the response has much greater detail and is very useful for writing/debugging regular expressions.- Parameters:
tokens
-- Returns:
- an object representing the match, or null if no match is found.
-
find
Find the first match of the regular expression against tokens, starting at the specified index.- Parameters:
tokens
- tokens to match against.start
- index to start looking for a match.- Returns:
- an object representing the match, or null if no match is found.
-
lookingAt
Determine if the regular expression matches the beginning of the supplied tokens.- Parameters:
tokens
- the list of tokens to match.- Returns:
- an object representing the match, or null if no match is found.
-
lookingAt
Determine if the regular expression matches the supplied tokens, starting at the specified index.- Parameters:
tokens
- the list of tokens to match.start
- the index where the match should begin.- Returns:
- an object representing the match, or null if no match is found.
-
match
-
findAll
Find all non-overlapping matches of the regular expression against tokens.- Parameters:
tokens
-- Returns:
- an list of objects representing the match.
-
main
An interactive program that compiles a word-based regular expression specified in arg1 and then reads strings from stdin, evaluating them against the regular expression.- Parameters:
args
-
-