import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(\\d{10})_([A-Z][a-z]+)([A-Z][a-z]+)(\\.[a-zA-Z]{3,4})";
final String string = "1173216167_AgentWill.jpg\n"
+ "1173216768_BrooksHarold.jpg\n"
+ "1173299189_BurgessDon.jpg\n"
+ "1173299407_ConiglioMike.jpg\n"
+ "1173299438_CooperKaren.jpg\n"
+ "1173299499_CurtisChristopher.jpg\n"
+ "1173300038_ElmoreKim.jpg\n"
+ "1173300155_FarmerVicki.jpg\n"
+ "1173300181_FletcherSteve.jpg\n"
+ "1173300207_ForrenEddie.jpg\n"
+ "1173300279_McguckinLinda.jpg\n"
+ "1173300440_GourleyJj.jpg\n"
+ "1173300567_HeinslemanPam.jpg\n"
+ "1173300593_HondlKurt.jpg\n"
+ "1173300619_HornJeff.jpg\n"
+ "1173300646_HowardKen.jpg\n"
+ "1173300716_IvicIgor.jpg\n"
+ "1173300757_JainMike.jpg\n"
+ "1173300862_KainJack.jpg\n"
+ "1173302066_KennedyDoug.jpg\n"
+ "1173302338_KuhlmanKristin.jpg\n"
+ "1173302528_LangstronCarrie.jpg\n"
+ "1173302580_LynnKelly.jpg\n"
+ "1173302631_MacgormanDon.jpg\n"
+ "1173303489_MelnikovValery.jpg\n"
+ "1173303530_MorrowBrett.jpg\n"
+ "1173303596_MurnanJames.jpg\n"
+ "1173303818_OrtegaKiel.jpg\n"
+ "1173304172_RabinBob.jpg\n"
+ "1173304254_RollinsTonia.jpg\n"
+ "1173304421_SchmidtMike.jpg\n"
+ "1173304508_SchurrTerry.jpg\n"
+ "1173304851_StumpfGreg.jpg\n"
+ "1173304935_TarpKeli.jpg\n"
+ "1173305069_ToomeyRobert.jpg\n"
+ "1173305102_TorresSebastian.jpg\n"
+ "1173305301_WickerLou.jpg\n"
+ "1173305326_WittArthur.jpg\n"
+ "1173305357_WoodBim.jpg\n"
+ "1173305420_XuQin.jpg\n"
+ "1173305550_YussoufNusrat.jpg\n"
+ "1173305582_ZahraiAllen.jpg\n"
+ "1173305608_ZhangPengfei.jpg\n"
+ "1173305634_ZhangJian.jpg\n"
+ "1173305666_ZieglerConrad.jpg\n"
+ "1173305696_ZrnicDusan.jpg\n"
+ "1178031443_LewisJohn.jpg\n"
+ "1208811784_DoviakRichard.jpg\n"
+ "1208811993_KrauseJohn.jpg\n"
+ "1208812047_MansellTed.jpg\n"
+ "1208812483_PepplerRandy.jpg\n"
+ "1208812511_ReevesHeather.jpg\n"
+ "1208812542_RobertsBrett.jpg\n"
+ "1208812597_WaughSean.jpg\n"
+ "1248986831_Warde-David.jpg\n"
+ "1248987295_Smith--Travis.jpg\n"
+ "1248987685_Knopfmeier--Kent.jpg\n"
+ "1248987721_GRIFFIN-ERICA.jpg\n"
+ "1248987828_Brogden--Jeff.jpg\n"
+ "1248987872_Arthur-Ami.jpg\n"
+ "1249399247_Nemunaitis-Kodi.jpg\n"
+ "1258400095_Clark-Adam.jpg\n"
+ "1258400182_Stratman-Derek.jpg\n"
+ "1258755192_Schwarz--Chris.jpg\n"
+ "1271793238_humberto.jpg\n"
+ "1273024015_BrianKaney2003.jpg\n"
+ "1278003921_Butler-Sterling.jpg\n"
+ "1278004017_Reinke-Tracy.jpg\n"
+ "1278004036_Ryzhkov-Alexander.jpg\n"
+ "1278004055_Tang-Lin.jpg\n"
+ "1278004074_Wang-Yadong.jpg\n"
+ "1297362249_Jones-Thomas.jpg\n"
+ "1297362283_Potvin-Corey.jpg\n"
+ "1311024411_Crank-Linda.jpg\n"
+ "1311024437_Gao-Jidong.jpg\n"
+ "1311024633_Smith-Brandon.jpg\n"
+ "1391808396_Bowden-Katie.jpg\n"
+ "1401375264_Meitin_jose.jpg\n"
+ "1407171270_Carlin_Jacob.jpg\n"
+ "1407171306_Cocks_Stephen.jpg\n"
+ "1407171371_Creager_Gerald.jpg\n"
+ "1407171682_Kirstetter-Pierre.jpg\n"
+ "1407171749_Kuster_Charles.jpg\n"
+ "1407171773_Martinaitis_Steven.jpg\n"
+ "1407171792_Mirkovic_Djordje.jpg\n"
+ "1407171905_Shattuck_Micheal.jpg\n"
+ "1407171947_Snyder_Jeffrey.jpg\n"
+ "1407172034_Wadler_Joshua.jpg\n"
+ "1418052845_D-Wasielewski.jpg";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
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