const 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]*)(?=".*$)/gmi;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(^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]*)(?=".*$)', 'gmi')
const str = `Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
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}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CCH.WFM.ServiceTest", "Source\\Common\\Tests\\Unit Tests\\ServiceTest\\CCH.WFM.ServiceTest.csproj", "{94E3C16B-DFBA-403A-95F9-37FAB7AB88ED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestFramework", "..\\test\\TestFramework\\TestFramework.csproj", "{3F56B03C-0883-4705-91BA-0979CAF6E719}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{044E36A5-189E-45B1-9753-397BC8ACD31A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{044E36A5-189E-45B1-9753-397BC8ACD31A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{044E36A5-189E-45B1-9753-397BC8ACD31A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{044E36A5-189E-45B1-9753-397BC8ACD31A}.Release|Any CPU.Build.0 = Release|Any CPU
{94E3C16B-DFBA-403A-95F9-37FAB7AB88ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94E3C16B-DFBA-403A-95F9-37FAB7AB88ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94E3C16B-DFBA-403A-95F9-37FAB7AB88ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94E3C16B-DFBA-403A-95F9-37FAB7AB88ED}.Release|Any CPU.Build.0 = Release|Any CPU
{3F56B03C-0883-4705-91BA-0979CAF6E719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F56B03C-0883-4705-91BA-0979CAF6E719}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F56B03C-0883-4705-91BA-0979CAF6E719}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F56B03C-0883-4705-91BA-0979CAF6E719}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 4
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs2013.prosystemfx.com/tfs/nextgen
SccLocalPath0 = .
SccProjectUniqueName1 = Source\\\\Common\\\\Tests\\\\Unit\\u0020Tests\\\\WFMTestFramework\\\\CCH.WFM.UnitTest.Framework.csproj
SccProjectName1 = Source/Common/Tests/Unit\\u0020Tests/WFMTestFramework
SccLocalPath1 = Source\\\\Common\\\\Tests\\\\Unit\\u0020Tests\\\\WFMTestFramework
SccProjectUniqueName2 = Source\\\\Common\\\\Tests\\\\Unit\\u0020Tests\\\\ServiceTest\\\\CCH.WFM.ServiceTest.csproj
SccProjectName2 = Source/Common/Tests/Unit\\u0020Tests/ServiceTest
SccLocalPath2 = Source\\\\Common\\\\Tests\\\\Unit\\u0020Tests\\\\ServiceTest
SccProjectUniqueName3 = ..\\\\test\\\\TestFramework\\\\TestFramework.csproj
SccProjectName3 = ../test/TestFramework
SccLocalPath3 = ..\\\\test\\\\TestFramework
EndGlobalSection
EndGlobal
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions