tags:

views:

29

answers:

4

When I have an Expression declared like

 someText = Regex.Replace(someText, @"/*.*?*/", "");

The Error Says System.ArgumentException: par"/*.*?*/" parsing - Nested quantifier *.

How to rewrite the code to avoid this error?

A: 

It doesn't like that you have this: ?*

This basically translates to "zero or one of the previous expression zero or more times" which seems a little odd. I'm pretty sure that's the same thing as saying "zero or more times". Can you explain what you are trying to do in more detail?

I suspect that if you change your regex to this it will do what you want:

(/*.*)*/

Abe Miessler
I am working in T4 template which generated Stored Procedure i took some line from web,it throws error
arun
I am unclear on what you are saying. Regardless of where it came from, your problem is what I mentioned above.
Abe Miessler
A: 

Maybe what is needed is a verbal description or sample of what you are trying to match. Here is my guess of what you want. I just added an escape for the "?" character.

string someText = Regex.Replace(someText, @"/*.*\?*/", "");
Russell McClure
I am working in subsonic to generate Stored Procedure,I copied some line from Web,it throws error.To list the entire code may confuse all.
arun
A: 

It appears you're trying to parse /* */ style comments. You may wish to try a regex like:

someText = Regex.Replace(someText, @"/\*.*\*/", "");

This ensures that your * are escaped as actual characters.

Joshua Rodgers
A: 

Here is a good site to test your regular expressions without much trouble:

http://www.regular-expressions.info/javascriptexample.html

I hope this will help a bit.

Robert