STRING::FIND_ALL
1g 2024-03-25 laplante@plcb.ca GOWEB/STRING — Find All Regex Matches in a Stringtitle: “STRING::FIND_ALL” version: “1.0.0” date: 2024-03-25 author: “laplante@plcb.ca” section: “1g” category: “GOWEB/STRING”
string::find_all Find All Regex Matches in a String
string::find_all(string, re/.../ [, nbmatch: int])
find_all(string, re/.../ [, nbmatch: int])
string::findAll(string, re/.../ [, nbmatch: int])
findAll(string, re/.../ [, nbmatch: int])
The find_all
function returns an array containing all successive matches of a given regular expression within a string.
By default, all matches are returned.
If the optional nbmatch
parameter is provided, it limits the number of matches returned.
string (string, required) The input string to search.
re/…/ (regular expression, required) The regular expression to match against.
nbmatch (integer, optional) The maximum number of matches to return. If omitted, returns all matches.
"2="; find_all("Pierre 56a Laplante 65b chantal 72c caroline", re/(\d+[a-z]+)/); "\n";
"3="; find_all("seafood fool", re/foo.?/);
Returns:
2 = ["56a","65b","7c"]
3 = ["food","fool"]