Back to all guides
3 min read·2026-11-27

Practical Regex Patterns & URL Encoding Cheat Sheet

Quick reference for everyday regular expression tokens and choosing between encodeURI and encodeURIComponent.

1. Essential Regex Tokens

Master \d (digits), \w (word chars), \s (whitespace), + (one or more), * (zero or more), ? (optional), {n,m} (quantifier), and ^ / $ (line anchors) to handle 80% of daily text parsing tasks.

2. Why URLs Use Percent-Encoding

RFC 3986 restricts URLs to a safe subset of ASCII characters. Non-ASCII characters (like Korean, emoji) and reserved symbols are converted into UTF-8 %XX byte sequences.

3. encodeURI vs. encodeURIComponent

Use encodeURI when encoding a complete URL while preserving ://?&=# delimiters. Use encodeURIComponent when safely embedding a value (such as a redirect URL or search term) inside a query parameter.

Try the Related Free Tools