tags:

views:

34

answers:

3

Hi, I have the following text:

started: Project: ProjectA, Configuration: Release Any CPU ------

I would like to get just the actual project name which in this example is "ProjectA".

I do have a regular expression "started:(\s)Project:(\s).*," which will give me "started: Project: ProjectA," and then I can use further basic string searching to return the project name but was wondering if there is any way I can just grab the actual project name without doing the extra string searching, maybe using a correct regular expression.

What I need is the string value between boundaries "started: Project: " and ",".
Any ideas?

A: 

Try this: started:\sProject:\s(.*),. I also recommend that you install Expresso. This is an excellent tool to debug and analyze regular expressions.

Kerido
Thanks that works and the tool is excellent too.
Rubans
+1  A: 

You can use "started: Project: ([^,]+)," and then get the value of the first group:

var m = regex.Match("....");
string project = m.Groups[1].Value;
Pent Ploompuu
A: 

If a project name cannot contain a comma, this should work:

started:\sProject:\s(.*?),
jasonbar