Common Regular Expression Grammar Quick Reference Table
Common Examples
Email Address
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ Phone Number (CN)
^1[3-9]\d{9}$ ID Card (CN)
^\d{15}$ |\d{18}$ Common Modifiers
i (case-insensitive)
Ignores case while matching. /hello/i matches Hello, HELLO, hello.
g (global)
Finds all matches, not just the first. /a/g matches three 'a's in 'banana'.
m (multiline)
Makes `^` and `$` match line start/end instead of string start/end.
s (single-line/dot-all)
Makes `.` match newlines as well.
Usage Tips
Use online tools (like RegexToolBox) to test and debug patterns in real time. Start simple and build up complexity. Remember to escape backslashes in string literals depending on your programming language.