| |
|
 |
Regular Expressions explained
|
This article will give you an introduction to the world of regular expressions. I'll start off with explaining what regular expressions are and introduce it's syntax, then some examples with varying complexity and last a list of tools which use regular expressions.
Concept
A regular expression is a text pattern consisting of a combination of alphanumeric characters and special characters known as metacharacters. A close relative is in fact the wildcard expression which are often used in file management. The pattern is used to match against text strings. The result of a match is either successful or not, however when a match is successful not all of the pattern must match, this is explained later in the article.
You'll find that regular expressions are used in three different ways: Regular text match, search and replace and splitting. The latter is basicly the same as the reverse match ie. everything the regular expression did not match.
Regular expressions are often simply called regexps or RE, but for consistency I'll be referring to it with it's full name.
Due to the versatility of the regular expression it is widely used in text processing and parsing. UNIX users are probably familiar with them trough the use of the programs, grep, sed, awk and ed. Text editors such as (X)Emacs and vi also use them heavily. Probably the most known use of regular expressions are in the programming language Perl, you'll find that Perl sports the most advanced regular expression implementation to this day.
Comment List
| Topic: |
Author: |
Time: |
|
another great regexp tool
|
S Church
|
01.03.2005 16:16
|
|
There's a free-as-in-beer development environment for Windows called HTML-Kit that's just great for writing scripts and web code. The Find or Find / Replace functions have a check box for Regexps, with a "Find All" button to highlight every instance matched by a regexp. The only drawback is that it assumes /is (case insensitivity and multiline).
VisualREGEXP mentioned in the article says it has no required supporting files, that the standalone executable is all that's needed. However, most Windows machines don't have the TCL/TK component "wish," which the README file claims is necessary for operation. Wish might be available somewhere online as a precompiled binary without having to install all of TCL/TK, but I'm not motivated enough to google it at the moment.
|
|
Email match
|
David Robarts
|
15.01.2005 22:45
|
|
Some valid email addresses will fail this expression (and some invalid addresses pass).
[a-z0-9_-]+(.[a-z0-9_-]+)*@[a-z0-9_-]+(.[a-z0-9_-]+)+
The underscore character is not allowed in the domain part of the email address and some additional characters are allowed in the username part.
This might be better:
[a-z0-9_-]+(.[a-z0-9_-+]+)*@[a-z0-9-]+(.[a-z0-9-]+)+
|
|
can't see the graphic
|
x x
|
02.11.2001 01:59
|
|
I can't see the graphic towards the bottom to demonstrate the usage of < >
|
|
 |
|
|