Upcoming Course: Code Your Own Business w/ React + GraphQL!
We're live-coding on Twitch! Join us!


This method is a called against a regular expression and returns the matching values in the string. The return value is an array containing the matched values. If no matches are found within the string, null is returned.

"hello world".match(/[el]/gi)
// ["e", "l", "l", "l"]


const matchedStrings = string.match(regex)

1 Parameter

regex This is the regular expression to search for within the string - required

Returns an array

It returns an array of all matched characters in the string.

Common Uses and Snippets

Extract specific information from a string

This method can be used to extract info from a string. Like getting an email address from a sentence.

Like this article? Follow @iChuloo on Twitter