Is there any way to split a Java String using a regular expression and return an array of backreferences?
As a simple example, say I wanted to pull the username & provider from a simple email address (letters only).
String pattern = "([a-z]+)@([a-z]+)\\.([a-z]{3})";
String email = "[email protected]";
String[] backrefs = backrefs(email,pattern);
System.out.println(backrefs[0]);
System.out.println(backrefs[1]);
System.out.println(backrefs[2]);
This should output
user
email
com