![]() |
|
||||||
Regular ExpressionsThe three: m// match (m not required) tr// translate s// substitutes"Meta characters" and their meaning \ escapes any character in a regular expression. ^ match at the begining $ match at the end of the string (line if /m) | logical orQuantifiers . Single character ? Match 0 or 1 times. * match 0 or more times. + match 1 or more times.Operators c Do not reset search position on a failed match when /g is in effect. g Match globally, i.e., find all occurrences. i Do case-insensitive pattern matching. m Treat string as multiple lines. o Compile pattern only once. s Treat string as single line. x Use extended regular expressions.Basic examples of matching if ($text ~= /string/){#The varible $text contains the word 'string'.} Would execute if the varible $text contained
'The phaser left a blastring' but not
For this last example to match we add an i (ignore case). if ($text ~= /string/i){#The varible $text contains the word 'string'.} You can also test to see if a pattern doesn't match a string with
So here are some common, helpful regexp examples. Return to Perl Help |
|||||||
[Perl help] [ABAP help] [MySQL help] [TCP/IP troubleshooting] [HTML help] [Feedback] [Humor] Advertise on Golden Ink's Georgia Network
|
|||||||