Home
Docker
Kubernetes
Java
Ubuntu
Maven
Archive
Java
|
Regular expressions
References
Example: Groups
References
See this page for more details java regular expressions:
https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/util/regex/Pattern.html
Example: Groups
final Pattern pattern = Pattern.compile("^([a-zA-Z]+)? (\\w+)$"); final Matcher matcher = pattern.matcher("ABC _012_"); if (matcher.matches()) { final String group1 = matcher.group(1); final String group2 = matcher.group(2); System.out.println(group1); System.out.println(group2); }
© 2022
mti
tek