Regular Expressions
Advanced Pattern Filtering
-
- Given sufficient time and patients, a lot can be accomplished with pattern
filtering
- This example swaps columns of a colon-delimited string pair
$myString =
"firstname:lastname";
$myString =~ s/([a-z]*):([a-z]*)/\2:\1/i;
#
Yields: "lastname:firstname";
- The () delimiters means
"remember" this part of the pattern
- The \# pair means
"restore" a numbered part of the pattern