Regex One-Liners are a concise way to use regular expressions to perform tasks in a single line of code. Here are some common regex one-liners in English:
Common Regex One-Liners
- Match an email address:
^[\w\.-]+@[\w\.-]+\.\w+$
- Find numbers in a string:
\b\d+\b
- Check for a valid URL:
^https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+
- Remove whitespace characters:
\s+
- Match dates in the format YYYY-MM-DD:
^\d{4}-\d{2}-\d{2}$
For more examples and details, check out our Regex One-Liners Guide.
To learn more about regular expressions, you can explore our Regex Basics section.