I am trying to retrieve the guids of projects within a .sln file using regular expressions
So, for instance, if I have in the file a project like this:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SomeProject", "SomeProject\SomeProject.csproj", "{F5EF941A-49AD-404D-9EB1-209A75D4113F}"
EndProject
I would do something like this in my script:
$projectsInSolution = Select-String "$file" -pattern 'Project'
$lineProjectsInFile = $projectsInSolution -match " `"{\S*}"
In the regular expression, I leave the whitespace because the real guid is F5EF941A-49AD-404D-9EB1-209A75D4113F
However, when I run this, I get
C:\...\...\...\....sln:6:Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SomeProject",
"SomeProject\SomeProject.csproj", "{F5EF941A-49AD-404D-9EB1-209A75D4113F}"
Why I am not getting the guid only?
I tested it in regexr.com and it seems so be working
Thank you
Edit
This is what I am doing now. But, not getting anything
$projectsInSolution = Select-String "$solutionFileStr" -pattern 'Project'
$lineProjectsInFile = $projectsInSolution -match "(?<={)[^}]+(?=}`"\s*EndProject)"
ForEach($line in $lineProjectsInFile)
{
Write-Output "$line"
}