Applies a regular expression to a string and returns an array with the first match.
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.
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 match('Hello, p5*js!', '[a-z][0-9]') would return the array ['p5'].
Note: If no matches are found, null is returned.
Ejemplos
Sintaxis
match(str, regexp)
Parámetros
str
String:
string to search.
regexp
String:
regular expression to match.
Returns
String[]: match if found.
This page is generated from the comments in src/utilities/string_functions.js . Please feel free to edit it and submit a pull request!