This uses golangs native regex functions under the hood - See their docs for the supported syntax.
Case insensitive tip: prefix the regex with (?i) - e.g. test("(?i)cats)".
This operator returns the substring match details of the given regEx.
Capture returns named RegEx capture groups in a map. Can be more convenient than match depending on what you are doing.
Returns true if the string matches the RegEx, false otherwise.
Substitutes matched substrings. The first parameter is the regEx to match substrings within the original string. The second is a what to replace those matches with. This can refer to capture groups from the first RegEx.
String blocks, bash and newlines
Bash is notorious for chomping on precious trailing newline characters, making it tricky to set strings with newlines properly. In particular, the $( exp )will trim trailing newlines.
For instance to get this yaml:
Using $( exp ) wont work, as it will trim the trailing new line.