Function: IF_MATCH
Syntax: IF_MATCH(target, regex1, result_if_regex1, [regex2, result_if_regex2], ..., [else_result])
Description: Evaluates the target
against a list of regular expressions (regexes) and return the result value from the first matching regex. If no regexes are matched then the else_result
is returned (or null
if none is specified). All the result values must have the
same type.
Note that matching is case insensitive by default. You can make the regex case sensitive by adding (?c)
at the beginning of your regex.
Sample usage:
IF_MATCH("foo_bar", "^foo", 1, "^bar", 2)
will return1
IF_MATCH("bar_foo", "^foo", 1, "^bar", 2)
will return2
IF_MATCH("some_word", "^foo", 1, "^bar", 2)
will returnnull
, since no regexes match the target value and there are no fallback valuesIF_MATCH("some_word", "^foo", 1, "^bar", 2, 10)
will return10
, since it is the fallback valueIF_MATCH(label_names, "(bug|defect)", "bug", "(feat|improvement)", "feature", "other")
will reduce labels (e.g. on an issue or PR) to a single keyword using regex matching.IF_MATCH(sub_type, "(bug|defect)", "bug", "(feat|improvement)", "feature", "other")
will regroup an issue sub-type (e.g. from Jira) into broader categories using regex matching.