pattern matching

Pattern matching in switch statements and beyond.

Groovy Regular Expressions – Pattern Matching with 12 Tested Examples

Groovy regex and regular expressions come with dedicated operators and concise syntax. See 12 tested examples covering regex operators, pattern matching, find, match, and replace. Complete guide for Groovy 5.x. “Some people, when confronted with a problem, think ‘I know, I’ll use regular expressions.’ Now they have two problems. Unless they’re using Groovy – then they just have one elegant solution.” Adapted from Jamie Zawinski Last Updated: March 2026 | Tested on: Groovy 5.x, Java 17+ | Difficulty: Intermediate | ... Read More

10 Groovy Switch Statement Examples with Pattern Matching

The enhanced Groovy switch statement goes far beyond Java’s version. See 10 examples matching strings, ranges, regex, classes, and closures. Tested on Groovy 5.x. “Java’s switch is a gate with a few locks. Groovy’s switch is a gate that accepts fingerprints, retina scans, and a secret handshake.” Martin Fowler, Refactoring Last Updated: March 2026 | Tested on: Groovy 5.x, Java 17+ | Difficulty: Beginner to Intermediate | Reading Time: 20 minutes The groovy switch statement goes far beyond what Java ... Read More