| A regular expression is a special
template type allowing you to create effective checks and substring
changes in data. An expression consists of usual characters and
meta symbols.
Most popular meta symbols and language clauses are:
| Item |
Match with |
| ^ |
the beginning of line |
| $ |
the end of line |
| . |
any character |
| [ ] |
characters in set |
| [^ ] |
characters not in set |
| | |
previous or next pattern |
| ? |
previous pattern 0 or 1 times |
| + |
previous pattern 1 or more times |
| * |
previous pattern 0 or more times |
| ( ) |
group pattern and remember to \n variable |
If part of the expression is enclosed in brackets, after the
matching is over, the substring value gets into a variable of the
type \n, where n is the number of the expression from the beginning
of the string. These variables can be used only in replace actions.
Useful regular expressions
| Regexp |
Description |
| ^[0-9A-Fa-f]+$ |
Hexadecimal number |
| ^\\(\\d{3}\\) ?\\d{3}[- ]\\d{4}$ |
Phone number (NNN) NNN-NNNN |
| ^^\\+[1-9] \\(\\d{3}\\) ?\\d{3}[- ]\\d{4}$ |
International phone number +N (NNN) NNN-NNNN |
| ^http\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(/\\S*)?$ |
URL |
|
^[0-9a-zA-Z_\\.]+@([0-9a-zA-Z_\\-]+?\\.){1,2}[a-zA-Z]{2,4}$/td> |
E-mail |
|