Regular expression

Sample Expression.

1. Email Address
Single email (xxx@xxx.com)
((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}

Email with semicolon
(xxx@xxx.com; aaa@aaa.com; bbb@bbb.com)


2. Zip Code (32082)

3. Phone Number (111-111-1111)
((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}


What is Regular expression?

In computing, a regular expression is a string that is used to describe or match a set of strings, according to certain syntax rules.

Regular expressions are used by many text editors and utilities to search and manipulate bodies of text based on certain patterns. Many programming languages support regular expressions for string manipulation. For example, Perl and Tcl have a powerful regular expression engine built directly into their syntax. The set of utilities (including the editor ed and the filter grep) provided by Unix distributions were the first to popularize the concept of regular expressions. "Regular expression" is often shortened in speech to regex, and in writing to regexp or regex (singular) or regexps, regexes, or regexen (plural).

As an example of the syntax, the regular expression \bex can be used to describe (and search for) all of the instances of the string "ex" that occur at word breaks (signified by the \b). Thus in the phrase, "Texts for expert experimenters," the regular expresssion \bex returns the "ex" in "expert" and "experimenters," but not in "Texts" (because the "ex" occurs inside the word there and not at the word break).

Many modern computing systems provide wildcard characters in matching filenames from a file system. This is a core capability of many command-line shells and is known as globbing. Wildcards differ from regular expressions in that they can only express very restrictive forms of alternation.

more information please read http://en.wikipedia.org/wiki/Regular_expression

No comments: