Reading — step 1 of 5
Learn
~1 min readGenerators and Regex
Regex literals use /pattern/flags:
js
Flags: i (case-insensitive), g (all matches, not just the first), m (multiline ^/$), s (dot matches newline), u (unicode-aware).
Key patterns:
\ddigit,\wword char,\swhitespace^start of line/string,$end.any char (except newline by default)*zero or more,+one or more,?zero or one(...)capture group,(?:...)non-capturing[abc]character class,[^abc]negated
For capture groups, use .match() (single match) or .matchAll() (iterator over all matches).
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…