Groovy & Java Regex Match and Find
Groovy provides some operators to have an efficient way to create pattern, find or test regex compared with Java.
Here are some common use case in Groovy and Java,
- create a pattern
In Groovy,
With Java,- find with Regex
In Groovy,
With Java,Java
* test with Regex Pattern pattern = Pattern.compile("pattern");
Matcher matcher = pattern.matcher("string");
if (matcher.find()) {
var str = matcher.group(1);
}
In Groovy,
With Java, or