Regular expressions are common in many programming languages and Unixish utilities and provide a way to describe the format of text strings. You can write a pattern and then see if a string matches it, or look for all matches, or replace them all with something else, and so on. Here is an example of a regular expression matching typical (but not all) HTTP URLs with optional query strings and fragments:
http://([a-z0-9-]+\.)+[a-z0-9-]+/[^\s#?]*(\?[^\s?#)+?(#[^\s?#)+?
J2SE 1.4 supports regular expressions natively in the java.util.regex package. For earlier versions of Java, or for more choices, you can use:
Mastering Regular Expressions at http://www.oreilly.com/catalog/regex2/ is a good introduction and covers advanced usage, including Java (this chapter is available online).
|