Click here to Skip to main content
15,922,630 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have a bunch of exceptions in a file and I want to catch those exceptions by using regular expression. For that the first expression has to match with 'System.' and last expression has to match with the Exception.

How many exception are there in that file I can find out? Please tell me what is the expression for System.NullRefferenceException etc)
or how to write custom exception expression.

I have reffered the Regex website but I did not found anything for my requirement.
Posted
Updated 2-Jan-11 18:55pm
v2
Comments
Sergey Alexandrovich Kryukov 3-Jan-11 1:36am    
Sounds like a terrifying abuse of exception technology which is so good by itself. Why all that?
Keith Barrow 3-Jan-11 2:47am    
Is this a log file and you are trying to parse out exception details written to it?

1 solution

How about:
^System\..*Exception$

the ^ says that the match has to start at the beginning of the line
\. to mach the .
. matches any character
* zero or more times
$ end of line

Take a look at:
.NET Framework Regular Expressions
[^]
and
Regular Expression Language Elements
[^]

Regards
Espen Harlinn
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900