YouTip LogoYouTip

Regex Tutorial - Patterns and Matching

Regex Basics

\d      # digit
\w      # word character
\s      # whitespace
.       # any character
*       # 0 or more
+       # 1 or more
?       # 0 or 1
{n}     # exactly n

Examples

/^\d{3}-\d{4}$/         # phone: 123-4567
/[\w.+-]+@[\w.-]+/      # email
/https?:\/\/[^\s]+/     # URL

Summary

  • \d, \w, \s are the most common character classes
  • Quantifiers control repetition
← Markdown Tutorial - Syntax GuiTailwind CSS Tutorial - Gettin β†’