regex
regular expression: a system of pattern masks to describe strings to search for, sort of a more generalised wildcarding. You can use them to scan text to extract data embedded in boilerplate. You can use them to replace boilerplate patterns.
Introduction
Examples
Other Regex Engines
Negative Regex
Quoting, why you need \\\\
Matching vs Finding vs LookingAt
Recipes for Quoting
Splitting
Regex Variations Table
Tips
Multiple Characters
String
Awkward Characters
Books
Terminology
Learning More
Pattern Flags
Links
IntroductionJDK 1.4 introduces the java.util.regex package. If they don’t work, use Wassup to check out the version of Java you are using. You may be inadvertently using an old one. Perl-like Regex expressions are compiled into a Pattern (parsed into an internal state machine format, not byte code). You don’t use a constructor to create a Pattern; you use the static method Pattern.compile(String). Then you create a Matcher object with Pattern. matcher(String) feeding it the String you wonder if matches the pattern. Finally, you call Matcher. matches to see if the xfString fits the pattern. There are many other things you can do, for example, to find multiple matches in your String.
Regex cannot do tasks like look for balanced ( ) or deal with a simple precedence grammar. For that you need a parser.