The match()
function returns all matches of the regular expression as a list.
match(string, string)
string.match(string)
Code language: JavaScript (javascript)
Example Formulas
match("Thomas 123 Frank 321", "\d+") /* Output: ["123", "321"] */
"Crew includes Luffy, the captain, Sanji, the cook, Nami, the navigator, and several others"
.match(
"(?<!^)[A-Z]\w+\b"
)
Code language: JavaScript (javascript)
The second example here uses a negative lookbehind to ensure the match doesn’t start at the beginning of the string. This prevents the word “Crew” from being included in the matches.