Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Fun with regex group names
import java.util.regex.Matcher
import java.util.regex.Pattern
Map splitLabel(String label) {
Pattern labelPattern = Pattern.compile('(?<column>^[A-Za-z]+)(?<side>\\d)(?<row>\\d+$)')
Matcher labelMatcher = labelPattern.matcher(label)
String columnLabel ="column")
Integer sideLabel = Integer.parseInt("side"))
Integer binNumber = Integer.parseInt("row"))
return [
side: sideLabel,
column: columnLabel,
bin: binNumber
println splitLabel('AA101')
println splitLabel('X11')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.