Regex take too long to match the result

Posted by Joe Ijam on Stack Overflow See other posts from Stack Overflow or by Joe Ijam
Published on 2010-12-29T10:45:24Z Indexed on 2010/12/29 10:54 UTC
Read the original article Hit count: 320

Filed under:
|
|

Hi all

I have this regex pattern

<(\d+)>(\d+\.\d+|\d{4}\-\d+\-\d+\s+\d{2}:\d{2}:\d{2})(?:\..*?)*\s+(ALER|NOTI)

and this is my input (will not matched at all)

<150>2010-12-29 18:11:30.883 -0700 192.168.2.145 80 192.168.2.87 2795 "-" "-" GET HTTP 192.168.2.145 HTTP/1.1 200 36200 0 1038 544 192.168.2.221 80 540  SERVER DEFAULT PASSIVE VALID /joomla/ "-" http://192.168.2.145/joomla/index.php?option=com_content&view=a be4d44e8f3986183a87991398c1c212e=1;      be4d44e8f3986183a87991398c1c212e=1

This will return not matched result but it takes too long to output the result. Since i have a thousand of logs/inputs in a second, it should finish very fast for every single log/input. Sometime it reaches CPU 100%.

Can anyone help me to solve this regex problem?

Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about regex