Search with regular expression

S

sowen

hi, folks

I am doing a automate tool to remove a project reference from the
VS.NET solution file.

Suppose the sln file has this project definition

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project", "..\..
\..\Project.csproj", "{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}"

How exactly can I use regular expression to find this project
definition? and read the project GUID
"{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}"?


because this is just the first step, if you open any your own solution
file, you will see this GUID will specify the build configuration of
this project. so I have to grab this piece then later I can remove the
following:

{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Debug|Any CPU.ActiveCfg =
Debug|Any CPU
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Debug|Any CPU.Build.0 = Debug|
Any CPU
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Debug|x86.ActiveCfg = Debug|
x86
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Debug|x86.Build.0 = Debug|x86
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Release|Any CPU.ActiveCfg =
Release|Any CPU
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Release|Any CPU.Build.0 =
Release|Any CPU
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Release|x86.ActiveCfg =
Release|x86
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Release|x86.Build.0 = Release|
x86

I am kind of losing track here. Can anyone give me a hint, Thanks a
lot!
 
R

raylopez99

Sorry I can't help Sowen. I don't even know what "regular expression"
means. I was going to suggest some string substring search
algorithms, but I see this is a different problem it seems.

Good luck!
RL
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,
Why you want to use regex?
You can use String.LastIndexOf.
 
I

Ignacio Machin \( .NET/ C# MVP \)

A

Arnshea

hi, folks

I am doing a automate tool to remove a project reference from the
VS.NET solution file.

Suppose the sln file has this project definition

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project", "..\..
\..\Project.csproj", "{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}"

How exactly can I use regular expression to find this project
definition? and read the project GUID
"{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}"?

because this is just the first step, if you open any your own solution
file, you will see this GUID will specify the build configuration of
this project. so I have to grab this piece then later I can remove the
following:

{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Debug|Any CPU.ActiveCfg =
Debug|Any CPU
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Debug|Any CPU.Build.0 = Debug|
Any CPU
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Debug|x86.ActiveCfg = Debug|
x86
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Debug|x86.Build.0 = Debug|x86
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Release|Any CPU.ActiveCfg =
Release|Any CPU
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Release|Any CPU.Build.0 =
Release|Any CPU
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Release|x86.ActiveCfg =
Release|x86
{9D8A6B4A-8B37-4C2E-80B9-0DA4C5EF33B1}.Release|x86.Build.0 = Release|
x86

I am kind of losing track here. Can anyone give me a hint, Thanks a
lot!

Try

^Project\(\"({.*?})\".*\"({.*?})\"$

the first ID will be in match.Groups[1], the second ID will be in
match.Groups[2].
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top