Wednesday, September 22, 2010

Regular Expressions syntax

Commonly, use of Regular Expressions in Java will look something like this:

Pattern pattern = Pattern.compile("INSERT REGULAR EXPRESSION");
Matcher matcher = pattern.matcher("INSERT INPUT STRING TO SEARCH");
boolean found = false;
while (matcher.find()) {
...do something...
}


def:

* A Pattern object is a compiled representation of a regular expression.
* A Matcher object is the engine that interprets the pattern and performs match operations against an input string.

No comments:

Post a Comment