Table of contents
  1. RegEX
    1. Use with replace and findall
    2. Create String and compare
    3. -closure for where-
    4. Use groups




RegEX

=~ will look for partial match ==~ look for an exact match

Use with replace and findall

“LBlsBF4wUp”.replaceAll(/[\d\sa-zA-Z.!?\-\’]/)

Create String and compare

-closure for where-

Use groups

def replacedTxt = txt.replaceAll(/.*(\d{2}-\d{2}-\d{4}).*(Gr.*)./) { all, date, lang ->
    def dateObj = Date.parse('dd-MM-yyyy', date)
    "The text '$all' was created with $lang on a ${dateObj.format('EEEE')}."
}