Regular Expressions
Previous  Top  Next

Regular Expressions are used in many programming languages and PERL is no exception here. Regular Expressions are well supported and can be useful in a lot of ways. So what are they good for? With Regular Expressions you can easily find and manipulate information in strings. Let's start with the easier one, finding information. Before I start digging in I'll list a table with some major commands you will be needing. Don't worry about their meaning – just refer to it as you need it.

\s || \S      space || no space
\w || \W      word || no word (word also means a combination of letters (without space))
\d || \D      digit || no digit
\b || \B      word border || no word border

^      beginning of line
$      end of line

[12468]      quantity (iteration)
[3-7]      quantity (scope)
[^456]      excluded quantity (iteration)
[^3-9]      excluded quantity (scope)

.      any character (exept new line)
*      no or any occurence
?      no or one occurence
+      one or any occurence

a|b|c      alternatives