Hi, for all those who do not understand or are interested in Perl Regular Expressions, here is a small explanation of the symbols (source: http://www.troubleshooters.com/codecorn/littperl/perlreg.htm).
Another interesting article can be found here:
http://www.grymoire.com/Unix/Regular.html
Using Simple "Wildcards" and "Repetitions"
Calling these "wildcards" may actually conflict with the theoretical grammar and syntax of Perl, but in fact is the most intuitive way to think of it, and will not lead to any coding mistakes.
. – Match any character
\w – Match "word" character (alphanumeric plus "_")
\W – Match non-word character
\s – Match whitespace character
\S – Match non-whitespace character
\d – Match digit character
\D – Match non-digit character
\t – Match tab
\n – Match newline
\r – Match return
\f – Match formfeed
\a – Match alarm (bell, beep, etc)
\e – Match escape
\021 – Match octal char (in this case 21 octal)
\xf0 – Match hex char ( in this case f0 hexidecimal)
You can follow any character, wildcard, or series of characters and/or wildcard with a repetiton. Here's where you start getting some power:
* – Match 0 or more times
+ – Match 1 or more times
? – Match 1 or 0 times
{n} – Match exactly n times
{n,} – Match at least n times
{n,m} – Match at least n but not more than m times
Symbol Explanations:
=~
This operator appears between the string var you are comparing, and the regular expression you're looking for (note that in selection or substitution a regular expression operates on the string var rather than comparing). Here's a simple example:
$string =~ m/Bill Clinton/; #return true if var $string contains the name of the president
$string =~ s/Bill Clinton/Al Gore/; #replace the president with the vice president
!~
Just like =~, except negated. With matching, returns true if it DOESN'T match. I can't imagine what it would do in translates, etc.
/
This is the usual delimiter for the text part of a regular expression. If the sought-after text contains slashes, it's sometimes easier to use pipe symbols (|) for delimiters, but this is rare. Here are simple examples of the slash operator:
$string =~ m/Bill Clinton/; #return true if var $string contains the name of the president
$string =~ s/Bill Clinton/Al Gore/; #replace the president with the vice president
m
The match operator. Coming before the opening delimiter, this is the "match" operator. It means read the string expression on the left of the =~, and see if any part of it matches the expression within the delimiters following the m. Note that if the delimiters are slashes (which is the normal state of affairs), the m is optional and often not included. Whether it's there or not, it's still a match operation. Here are some examples:
$string =~ m/Bill Clinton/; #return true if var $string contains the name of the president
$string =~ /Bill Clinton/; #same result as previous statement
^
This is the "beginning of line" symbol. When used immediately after the starting delimiter, it signifies "at the beginning of the line". For instance:
$string =~ m/^Bill Clinton/; #true only when "Bill Clinton" is the first text in the string
$
This is the "end of line" symbol. When used immediately before the ending delimiter, it signifies "at the end of the line". For instance:
$string =~ m/Bill Clinton$/; #true only when "Bill Clinton" is the last text in the string
i
This is the "case insensitivity" operator when used immediately after the closing delimiter. For instance:
$string =~ m/Bill Clinton/i; #true when $string contains "Bill Clinton" or BilL ClInToN"