Regular Expression Basic Characters
Regular Expressions use punctuation characters to tell the system what to do when looking for something. These characters can call different behaviors, like:
- Find a specific character
- Look for this particular thing and make sure it's not targeted
- Something within this range
By using basic characters in regular expressions, you can:
- Achieve a wide range of usability to validate expressions
- Keep your code crisp and clean as well as get faster validation of expressions
Here's a list of the things you'll be using most often:
Common Regex Characters
| Character Pattern | Name | Description |
|---|---|---|
| . | Period | Matches any character |
| x* | Star/Asterisk | Matches zero or more of the preceding character (in this case, x) |
| .* | Period-Star | Matches any number of any character (anything, basically!) |
| x+ | Plus | Matches one or more of the preceding characters (in this case, x) |
| \ | Backslash | The next character is to be treated differently or "escaped." |
| x? | Question Mark | Preceding character is optional. Matches zero or one occurrence |
| \d | Escape-d | Matches any single digit (0-9) |
| \w | Escape-w | Matches any word character (letters, numbers, and underscore) |
| x|y | Or pipe | Matches x OR y |
| (hats?|scar(f|ves)) | Parentheses |
Groups specific items together. This example will match hat, hats, scarf, scarves |
| [xyz] | Brackets | Specify ranges of letters and numbers |
Please see this Note on Regular Expression Characters for additional information.
© 2005 - 2025 ProProfs