quest4tech.net

 

PERL

Practical Extraction and Reporting Language. It is a string processing scripting language.

Resources

Perl books UK
 
Perl books USA
 

Perl's Regular Expressions

Code
 
Description
. any character
\t tab
\n new line
\r return
\f formfeed
\a alarm (bell, beep etc)
\e escape
\O octal character e.g. \O25 for octal 25
\x hex character e.g. \xf4 for hexidecimal f4

 
Code
 
Actual Description
\d [0-9] any digit
\w [a-zA-Z_0-9] any alphanumeric character
\s [\t\n\r\f] any whitespace character
\D [^0-9] any nondigit
\W [^a-zA-Z_0-9] any nonalphanumeric character
\S [^\t\n\r\f] any nonwhitespace character

 

Symbols

Symbol
 
Explanation Example
=~ Compare string with a regular expression.
!~ Negated form of =~
/ Delimiter
m Match operator. if ($browser =~ m/MSIE/) {....
[....] a class of characters between the square brackets.
^ Beginning of line symbol.
[^....] At the start of a class means NOT.
$ End of line symbol.
i Case insensitiviy.
\b At start or end of word, according to its position. matches free-standing word: /\bword\b/
\B Not at start or end of word, according to its position.
\g At end of pattern to save all matches. =~ m/pattern/g


Links

CPAN - Comprehensive Perl Archive Network
 

 


To add an entry or comment on the article, please fill in the comments form


Return to Top

Main Index


(c) Created by B V Wood.

 Main Index
 Comments

UK SPONSERS

 
USA SPONSERS