need help with regular expression in c#

i need some help coming up with a regular expression that represent the following code:

using (new SimpleSDOLogScope(
                      MediatorAgent.Common,
                      null, null, null,
                      typeof(BenefitGroup),
                      null, null, null,

"MediatorAgent.Common" and " typeof(BenefitGroup)" can be any set of legal characters (\w).  but the rest are string literals with spaces in between (number of spaces can vary).  thanks.
mmingfeilamAsked:
Who is Participating?
 
crysallusCommented:
Try this:

using\s+\(new\s+SimpleSDOLogScope\(\s*[\w.()]+\s*,\s*null\s*,\s*null\s*,\s*null\s*,\s*[\w.()]+\s*,\s*null\s*,\s*null\s*,\s*null\s*,

Open in new window

0
 
käµfm³d 👽Commented:
Something like this, then?
string pattern = @"using\s*\(new\s+SimpleSDOLogScope\s*\(\s*MediatorAgent\s*\.\s*Common\s*,\s*(?:@""[^""]*""\s*,\s*){3}typeof\s*\(\s*BenefitGroup\s*\s*\)\s*,\s*(?:@?""[^""]*""\s*,\s*){3}";

Open in new window

0
 
käµfm³d 👽Commented:
P.S.

I forgot to ask:  is your pattern intended to be used in code, or in the Find/Replace dialog of Visual Studio?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
käµfm³d 👽Commented:
If this for Find/Replace, try:

using:Wh*\(new:Wh+SimpleSDOLogScope:Wh*\(:Wh*MediatorAgent\.Common:Wh*,:Wh*(\@*"[^"]*":Wh*,:Wh*)^3typeof\(BenefitGroup\):Wh*,:Wh*(\@*"[^"]*":Wh*,:Wh*)^3

Open in new window

0
 
mmingfeilamAuthor Commented:
it's intended for use in the find/replace dialog box in vs 2008.  

crysallus: you solution didn't return anything.
kaufmed: you first solution contains syntax error, and your second solution didn't return anything.
0
 
käµfm³d 👽Commented:
you first solution contains syntax error, and your second solution didn't return anything.
Second solution was intended for Find/Replace. Not surprising it didn't work in code  = )

For the first, where is the syntax error? It worked fine for me.


string pattern = @"using\s*\(new\s+SimpleSDOLogScope\s*\(\s*MediatorAgent\s*\.\s*Common\s*,\s*(?:@""[^""]*""\s*,\s*){3}typeof\s*\(\s*BenefitGroup\s*\s*\)\s*,\s*(?:@?""[^""]*""\s*,\s*){3}";
string data = @"using (new SimpleSDOLogScope(
          MediatorAgent.Common,
          ""hello"", ""world"", ""hello world"",
          typeof(BenefitGroup),
          ""hello"", ""world"", ""hello world"",";

Console.WriteLine(System.Text.RegularExpressions.Regex.IsMatch(data, pattern));
Console.ReadKey();

Open in new window

0
 
mmingfeilamAuthor Commented:
what i means is that when i used the first expression in the find/replace dialog, i got a syntax error, as is expected.  but when i used your second expression, i didn't get anything back.  so can you test the second expression out using the VS2008 find/replace dialog?  also, is there any add-in out there that allows you to do find/replace using .net regular expressions?
0
 
käµfm³d 👽Commented:
I can't do screencasts from work, so I can only offer screenshots, but this was my test:

BeforeAfter
Make sure you have the "Use->Regular Expressions" option enabled.
0
 
käµfm³d 👽Commented:
And here is the beloved screencast  = )
kaufmed-505623.flv
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.