레퍼런스 matchAll()

matchAll()

Applies a regular expression to a string and returns an array of matches.

match() uses regular expressions (regex) to match patterns in text. For example, the regex abc can be used to search a string for the exact sequence of characters abc. See MDN. for more information about regexes. matchAll() is different from match() because it returns every match, not just the first.

The first parameter, str, is the string to search.

The second parameter, regex, is a string with the regular expression to apply. For example, calling matchAll('p5*js is easier than abc123', '[a-z][0-9]') would return the 2D array [['p5'], ['c1']].

Note: If no matches are found, an empty array [] is returned.

예제

구문

matchAll(str, regexp)

매개변수

str

string to search.

regexp

regular expression to match.

Notice any errors or typos? Please let us know. Please feel free to edit src/utilities/string_functions.js and open a pull request!

관련 레퍼런스