Stay organized with collections
Save and categorize content based on your preferences.
Finds all matches of a regular expression in a string.
A list of matches is returned, where each match has the starting index
(zero-based) of the matched substring and the substring itself. In the case of
overlapping matches, only the leftmost match is considered. If the overlapping
matches start at the same index, then the longest match is considered.
Arguments
Arguments
source
string
The source string to search.
regexp
string
The regular expression used for the search. Uses RE2 syntax.
Returns
A list of maps, where each map represents a match. The
map has the keys index and match whose values are the starting
index (int) of the substring and the substring itself (string),
respectively. The list is sorted by the index key. If no match is found,
an empty list is returned.
Raised exceptions
Exceptions
TypeError
If either source or regexp is not a string.
ValueError
If regexp is not UTF-8 encoded or is an invalid regular expression.
Examples
# Find match of regular expression in string# Returns `[{"index":0,"match":"Hello"},{"index":5,"match":"World"}]`-returnStep:return:${text.find_all_regex("HelloWorld", "Hello|World")}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Function: text.find_all_regex\n\nFinds all matches of a regular expression in a string.\n\nA list of matches is returned, where each match has the starting index\n(zero-based) of the matched substring and the substring itself. In the case of\noverlapping matches, only the leftmost match is considered. If the overlapping\nmatches start at the same index, then the longest match is considered.\n\nArguments\n---------\n\nReturns\n-------\n\nA list of maps, where each map represents a match. The\nmap has the keys `index` and `match` whose values are the starting\nindex (`int`) of the substring and the substring itself (`string`),\nrespectively. The list is sorted by the `index` key. If no match is found,\nan empty list is returned.\n\nRaised exceptions\n-----------------\n\nExamples\n--------\n\n```yaml\n# Find match of regular expression in string\n# Returns `[{\"index\":0,\"match\":\"Hello\"},{\"index\":5,\"match\":\"World\"}]`\n- returnStep:\n return: ${text.find_all_regex(\"HelloWorld\", \"Hello|World\")}\n```"]]