JavaScript Match

match() runs a regular expression against the string and returns the matches (or null when nothing matches). It is the entry point to pattern extraction — capturing groups, digits, words, anything a regex can describe.

Syntax

str.match(regex)

Examples

Input Arguments Output
"a1b2c3" "[0-9]" ["1"]
↳ Without the /g flag, only the first match is returned.

Gotchas

  • Returns null (not []) when there is no match — check before iterating.

Try it live

Type your input and see Match transform it instantly.

Description: Finds matches for a regular expression in a string.

Example: 'carrot cake'.match(/c/g) => ['c', 'c']

Want to go further? Chain Match with other functions in the visual Playground — pipe one output into the next and watch your data transform.

Related functions

© 2026 Heifara Buval