Skip to content

Instantly share code, notes, and snippets.

@ezhov-da
Last active March 10, 2019 12:16
Show Gist options
  • Save ezhov-da/e953a43d19f6f68493749b9bf5d8c770 to your computer and use it in GitHub Desktop.
Save ezhov-da/e953a43d19f6f68493749b9bf5d8c770 to your computer and use it in GitHub Desktop.
работа с группами
import java.util.logging.Logger;
import java.util.regex.*;
public class TTest {
private static final Logger LOG = Logger.getLogger(TTest.class.getName());
public static void main(String[] args) {
Pattern pattern = Pattern.compile("(?<user>[a-z]+)(?<number>\\d+)");
Matcher matcher = pattern.matcher("asfafa2123264asfafsa3f43431asfasf34");
while (matcher.find()) {
String user = matcher.group("user");
System.out.println("user: " + user);
String number = matcher.group("number");
System.out.println("number: " + number);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment