import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "@(.+?):";
final String string = "rainyear@hotmail.com:pepper\n"
+ "rajkomatt3@gmail.com:wehttam12\n"
+ "rakkasan240b@gmail.com:dn38416\n"
+ "rallytruckgnome@gmail.com:urban12\n"
+ "rammer388@gmail.com:ryanm08\n"
+ "ramonlopezjr@gmail.com:26may2001\n"
+ "ramsec@live.com:ramseywii1\n"
+ "randomhulu@gmail.com:moppel12\n"
+ "rangeman101@hotmail.co.uk:warcraft4\n"
+ "rangerkid1997@gmail.com:fetherolf5432\n"
+ "ranglinm@yahoo.com:rang94631\n"
+ "raphhashem@gmail.com:31951raph\n"
+ "rappe.austin@gmail.com:Elle4637096\n"
+ "ratof81@gmail.com:lovecraft1\n"
+ "raxarraxar@gmail.com:48oakao42\n"
+ "raylonlong@gmail.com:rayray12\n"
+ "rayvale.games@googlemail.com:fDbXh87Xfn\n"
+ "ray_2096@hotmail.com:hardys1996\n"
+ "rbenade@hotmail.ca:bandstra1\n"
+ "rcolegreco@gmail.com:Hell0W0rld\n"
+ "rdfenton@hotmail.com:scoots55\n";
final String subst = ":";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
// The substituted value will be contained in the result variable
final String result = matcher.replaceAll(subst);
System.out.println("Substitution result: " + result);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html