KW.pm | Regular Expressions | #12 |
Modifier | Meaning |
---|---|
/i | Ignore case in match |
/s | Let . match newline and ignore depricated $* variable |
/m | Let ^ and $ match next to embedded \n |
/x | Ignore whitespace and comments in regex |
/o | Compile pattern once only. |
m/^(\(\d{3}\))?\d{3}-\d{4}$/;matches the same thing as:
m/ ^ # The match must be at the very beginning ( # Start of a group \( # Literal ( \d{3} # Exactly three digits \) # Literal ) )? # The group may or may not be present in the match \d{3} # Exactly three digits -\d{4} # followed by a hyphen and four more digits $ # The match must be at the very end # in this case the match must be the whole string /x; # Remove comments and compress all excess whitespace
<< Previous | Index | Next >> | Copyright © 2002 Christopher Calzonetti |