Java Reference
In-Depth Information
Figure 4-2. REDemo with “Q not followed by u” example
One good way to think of regular expressions is as a “little language” for matching patterns
of characters in text contained in strings. Give yourself extra points if you've already recog-
nized this as the design pattern known as Interpreter. A regular expression API is an inter-
preter for matching regular expressions.
So now you should have at least a basic grasp of how regexes work in practice. The rest of
this chapter gives more examples and explains some of the more powerful topics, such as
capture groups. As for how regexes work in theory—and there are a lot of theoretical details
and differences among regex flavors—the interested reader is referred to in Mastering Regu-
lar Expressions . Meanwhile, let's start learning how to write Java programs that use regular
expressions.
Search WWH ::




Custom Search