Improving/Fixing a Regex for C style block comments
I'm writing (in C#) a simple parser to process a scripting language that looks a lot like classic C.

On one script file I have, the regular expression that I'm using to recognize /* block comments */ is going into some kind of infinite loop, taking 100% CPU for ages.

The Regex I'm using is this:

    /\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/


Any suggestions on why this might get locked up?

Alternatively, what's another Regex I could use instead?


More information:

 - Working in C# 3.0 targeting .NET 3.5;
 - I'm using the Regex.Match(string,int) method to start matching at a particular index of the string;
 - I've left the program running for over an hour, but the match isn't completed;
 - Options passed to the Regex constructor are `RegexOptions.Multiline` and  `RegexOptions.IgnorePatternWhitespace`;
 - The regex works correctly for 452 of my 453 test files.
Improving/Fixing a Regex for C style block comments
===

I'm writing (in C#) a simple parser to process a scripting language that looks a lot like classic C.

On one script file I have, the regular expression that I'm using to recognize /* block comments */ is going into some kind of infinite loop, taking 100% CPU for ages.

The Regex I'm using is this:

    /\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/


Any suggestions on why this might get locked up?

Alternatively, what's another Regex I could use instead?


More information:

 - Working in C# 3.0 targeting .NET 3.5;
 - I'm using the Regex.Match(string,int) method to start matching at a particular index of the string;
 - I've left the program running for over an hour, but the match isn't completed;
 - Options passed to the Regex constructor are `RegexOptions.Multiline` and  `RegexOptions.IgnorePatternWhitespace`;
 - The regex works correctly for 452 of my 453 test files.