import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(^Project\\(\"\\{[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\\}\"\\)\\s*=\\s*\"[\\w\\d-.]*\"\\s*,\\s*\")\\K([\\w\\d-.\\\\\\s]*)(?=\".*$)";
final String string = "Microsoft Visual Studio Solution File, Format Version 12.00\n"
+ "# Visual Studio 14\n"
+ "VisualStudioVersion = 14.0.25420.1\n"
+ "MinimumVisualStudioVersion = 10.0.40219.1\n"
+ "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"CCH.WFM.UnitTest.Framework\", \"Source\\Common\\Tests\\Unit Tests\\WFMTestFramework\\CCH.WFM.UnitTest.Framework.csproj\", \"{044E36A5-189E-45B1-9753-397BC8ACD31A}\"\n"
+ "EndProject\n"
+ "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"CCH.WFM.ServiceTest\", \"Source\\Common\\Tests\\Unit Tests\\ServiceTest\\CCH.WFM.ServiceTest.csproj\", \"{94E3C16B-DFBA-403A-95F9-37FAB7AB88ED}\"\n"
+ "EndProject\n"
+ "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"TestFramework\", \"..\\test\\TestFramework\\TestFramework.csproj\", \"{3F56B03C-0883-4705-91BA-0979CAF6E719}\"\n"
+ "EndProject\n"
+ "Global\n"
+ " GlobalSection(SolutionConfigurationPlatforms) = preSolution\n"
+ " Debug|Any CPU = Debug|Any CPU\n"
+ " Release|Any CPU = Release|Any CPU\n"
+ " EndGlobalSection\n"
+ " GlobalSection(ProjectConfigurationPlatforms) = postSolution\n"
+ " {044E36A5-189E-45B1-9753-397BC8ACD31A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n"
+ " {044E36A5-189E-45B1-9753-397BC8ACD31A}.Debug|Any CPU.Build.0 = Debug|Any CPU\n"
+ " {044E36A5-189E-45B1-9753-397BC8ACD31A}.Release|Any CPU.ActiveCfg = Release|Any CPU\n"
+ " {044E36A5-189E-45B1-9753-397BC8ACD31A}.Release|Any CPU.Build.0 = Release|Any CPU\n"
+ " {94E3C16B-DFBA-403A-95F9-37FAB7AB88ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n"
+ " {94E3C16B-DFBA-403A-95F9-37FAB7AB88ED}.Debug|Any CPU.Build.0 = Debug|Any CPU\n"
+ " {94E3C16B-DFBA-403A-95F9-37FAB7AB88ED}.Release|Any CPU.ActiveCfg = Release|Any CPU\n"
+ " {94E3C16B-DFBA-403A-95F9-37FAB7AB88ED}.Release|Any CPU.Build.0 = Release|Any CPU\n"
+ " {3F56B03C-0883-4705-91BA-0979CAF6E719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n"
+ " {3F56B03C-0883-4705-91BA-0979CAF6E719}.Debug|Any CPU.Build.0 = Debug|Any CPU\n"
+ " {3F56B03C-0883-4705-91BA-0979CAF6E719}.Release|Any CPU.ActiveCfg = Release|Any CPU\n"
+ " {3F56B03C-0883-4705-91BA-0979CAF6E719}.Release|Any CPU.Build.0 = Release|Any CPU\n"
+ " EndGlobalSection\n"
+ " GlobalSection(SolutionProperties) = preSolution\n"
+ " HideSolutionNode = FALSE\n"
+ " EndGlobalSection\n"
+ " GlobalSection(TeamFoundationVersionControl) = preSolution\n"
+ " SccNumberOfProjects = 4\n"
+ " SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}\n"
+ " SccTeamFoundationServer = https://tfs2013.prosystemfx.com/tfs/nextgen\n"
+ " SccLocalPath0 = .\n"
+ " SccProjectUniqueName1 = Source\\\\Common\\\\Tests\\\\Unit\\u0020Tests\\\\WFMTestFramework\\\\CCH.WFM.UnitTest.Framework.csproj\n"
+ " SccProjectName1 = Source/Common/Tests/Unit\\u0020Tests/WFMTestFramework\n"
+ " SccLocalPath1 = Source\\\\Common\\\\Tests\\\\Unit\\u0020Tests\\\\WFMTestFramework\n"
+ " SccProjectUniqueName2 = Source\\\\Common\\\\Tests\\\\Unit\\u0020Tests\\\\ServiceTest\\\\CCH.WFM.ServiceTest.csproj\n"
+ " SccProjectName2 = Source/Common/Tests/Unit\\u0020Tests/ServiceTest\n"
+ " SccLocalPath2 = Source\\\\Common\\\\Tests\\\\Unit\\u0020Tests\\\\ServiceTest\n"
+ " SccProjectUniqueName3 = ..\\\\test\\\\TestFramework\\\\TestFramework.csproj\n"
+ " SccProjectName3 = ../test/TestFramework\n"
+ " SccLocalPath3 = ..\\\\test\\\\TestFramework\n"
+ " EndGlobalSection\n"
+ "EndGlobal\n";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
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