Wednesday, January 2, 2008

Regular expression

Regular expression is a powerful technique for non-beginners to validate, replace or split text values. Use tools like RegExpress to test and learn regular expression syntax.

Validate a simple e-mail address.
Syntax: ^[a-z.]+@[a-z]+(\.+[a-z]+)+
^Matches the start of the string
[a-z.]+ Allow one or more lower case char a to z and dot
@Must contain one e-mail At character
[a-z]+Allow one or more lower case char a to z
(Begin sub expression
\.Must contain one dot
[a-z]Allow one or more lower case char a to z
)End sub expression
+One or more sub expression


Split one or more email addresses separated by comma or semicolon.
Syntax: [,;]+

[,;]Find separator comma or semicolon
+One or more separator