Regex Flags

Global, case-insensitive, multiline, dotall, unicode, sticky.

  • regex flags
  • case insensitive
  • global flag
  • dotall
  • unicode flag

Regex Flags

Global, case-insensitive, multiline, dotall, unicode, sticky.

Commands

CommandWhat it does
/p/iCase-insensitive
/p/gGlobal: all matches
/p/mCaret-dollar match per line
/p/sDot matches newlines too
/p/uFull unicode semantics
/p/ySticky: match at lastIndex

Example

const re = /error.*/gis;
text.matchAll(re)

FAQ

When do I need the s flag?

When matching across lines - otherwise the dot stops at newlines.

What breaks without the u flag?

Emoji split into lone surrogates, and unicode property classes require u.

คำถามที่พบบ่อย

When do I need the s flag?
When matching across lines - otherwise the dot stops at newlines.
What breaks without the u flag?
Emoji split into lone surrogates, and unicode property classes require u.

Regex