Regular Expression Will match...
foo The string "foo"
^foo "foo" at the start of a string
foo$ "foo" at the end of a string
^foo$ "foo" when it is alone on a string
[abc] a, b, or c
[a-z] Any lowercase letter
[^A-Z] Any character that is not a uppercase letter
(gif|jpg) Matches either "gif" or "jpeg"
[a-z]+ One or more lowercase letters
[0-9.-] Аny number, dot, or minus sign
^[a-zA-Z0-9_]{1,}$ Any word of at least one letter, number or _
([wx])([yz]) wy, wz, xy, or xz
[^A-Za-z0-9] Any symbol (not a number or a letter)
([A-Z]{3}|[0-9]{4}) Matches three letters or four numbers
Operator TypeExamplesDescription
Literal Characters
Match a character exactly
a A y 6 % @Letters, digits and many special
characters match exactly
$ ^ + \ ?Precede other special characters
with a to cancel their regex special meaning
Literal new line, tab, return
cJ cGControl codes
xa3Hex codes for any character
Anchors and assertions ^Field starts with
$Field ends with
[[:<:]]Word starts with
[[:>:]]Word ends with
Character groups
any 1 character from the group
[aAeEiou]any character listed from [ to ]
[^aAeEiou]any character except aAeEio or u
[a-fA-F0-9]any hex character (0 to 9 or a to f)
.any character at all
[[:space:]]any space character (space or )
[[:alnum:]]any alphanumeric character (letter or digit)
Counts
apply to previous element
+1 or more ("some")
*0 or more ("perhaps some")
?0 or 1 ("perhaps a")
{4}exactly 4
{4,}4 or more
{4,8}between 4 and 8
Add a ? after any count to turn it sparse (match as few as possible) rather than have it default to greedy
Alternation |either, or
Grouping ( )group for count and save to variable
Tags
Comments
Write the first comment
Leave a trace
Name *
Email *
Website
Anti SPAM * Code (1 + 3) =
Leave me a comment *
 
All comments are subject to editorial review
Post being viewed right now
Item date: 01.08.2009
Views: 2189
Item date: 01.01.2009
Views: 397
Item date: 08.03.2009
Views: 1610
Item date: 03.01.2009
Views: 1443
Item date: 10.04.2009
Views: 1231
Item date: 18.03.2009
Views: 2026
Item date: 09.10.2009
Views: 530
Item date: 16.06.2009
Views: 376
Item date: 04.02.2009
Views: 2082