| Regular Expression | Matches |
|---|---|
| foo | The string “foo” |
| ^foo | “foo” at the start of a string |
| foo$ | “foo” at the end of a string |
| ^foo$ | “foo” when it is alone on a string |
| [abc] | a, b, or c |
| [a-z] | Any lowercase letter |
| [^A-Z] | Any character that is not a uppercase letter |
| (gif | jpg) |
| [a-z]+ | One or more lowercase letters |
| [0-9.-] | A�ny number, dot, or minus sign |
| ^[a-zA-Z0-9_]{1,}$ | Any word of at least one letter, number or _ |
| ([wx])([yz]) | wy, wz, xy, or xz |
| [^A-Za-z0-9] | Any symbol (not a number or a letter) |
| ([A-Z]{3} | [0-9]{4}) |
| Function | Description |
|---|---|
| preg_match() | The preg_match() function searches string for pattern, returning true if pattern exists, and false otherwise. |
| preg_match_all() | The preg_match_all() function matches all occurrences of pattern in string. |
| preg_replace() | The preg_replace() function operates just like ereg_replace(), except that regular expressions can be used in the pattern and replacement input parameters. |
| preg_split() | The preg_split() function operates exactly like split(), except that regular expressions are accepted as input parameters for pattern. |
| preg_grep() | The preg_grep() function searches all elements of input_array, returning all elements matching the regexp pattern. |
| preg_ quote() | Quote regular expression characters |