The match operator checks to see of a variable contains the specified data.
Then you can setup a conditional statement to do something if the data's there
or if it is not.
Perl Regular Expressions |
| . | Matches any character except newline |
| [a-z0-9] | Matches any single character of set |
| [^a-z0-9] | Matches any single character not in set |
| \d | Matches a digit, same as [0-9] |
| \D | Matches a non-digita, same as [^0-9] |
| \w | Matches an alphanumeric (word) character [a-zA-Z0-9] |
| \W | Matches a non-word character [^a-zA-Z0-9] |
| \s | Matches a whitespar characteer (space, tab, newline) |
| \S | Matches a non-whitespace character |
| |
| \n | Matches a newline |
| \r | Matches a return |
| \t | Matches a tab |
| \f | Matches a formfeed |
| \b | Matches a backspace (inside [ ] only) |
| \0 | Matches a null character |
| \000 | Also matches a null character becasue... |
| \nnn | Matches an ASCII character of that octal value |
| \cX | Matches an ASCII control character |
| \metachar | Matches the character itself (\|, \., \*...) |
| |
| (abc) | Remembers the match for later backreference |
| \1 | Matches whatever first of parens matched |
| \2 | Matches whatever second set of parens matched |
| \3 | and so on... |
| |
| x? | Matches 0 or 1 x's, where x is any of above |
| x* | Matches 0 or more x's |
| x+ | Matches 1 or more x's |
| x{m} | Matches at exactly m x's |
| x{m,} | Matches at least m x's |
| x{m, n} | Matches at least m x's but no more than n |
| |
| abc | Matches all of a, b, and c in order |
| fee|fie|foe | Matches one of fee, fie or foe |
| |
| \b | Matches a word boundry (outside [ ] only) |
| \B | Matches a non-word boundry |
| ^ | Anchors match to the beginning of a line or string |
| $ | Anchors match to the end of a line or string |
s/PATTERN/REPLACEMENT/egimosx |
| e | Evaluate the right side as an expression. |
| g | Match globally, i.e. all occurrences. |
| i | Case-insensitive pattern matching. |
| m | Treat string as multiple lines. |
| o | Only compile pattern once, even if variables within it change. |
| s | Treat string as single line. |
| x | Use extended regular expressions |
| |
| $+ | the last pattern that was matched (useful when there are alternatives) |
| $& | the matched string |
| $` | everything before the matched string |
| $' | everything after the matched string |
| s/^=(\w+)/($1)/g; |