Skip to main content

replaceMatches

replaceMatches(text: String, glob: String, replacement: String) : String

Replaces every match of glob pattern in text with replacement. For example, replaceMatches("abc-123-def", "-*-","_") is "abc_def" and replaceMatches("abc-123-def", "-*-", "") is "abcdef".

Note that in replaceMatches wildcards * and ? do NOT match newline characters. For example, in the following example, afterText will have value "another\n":

text = """
!! abc
another
!! def

""";

afterText = replaceMatches(text, "!!*\n", "");

See also

Types

Functions