Re: Why this regex takes so long?
>>however try plugging it in here: It gives me the same result: Timout for PHP and Python (after about 3 sec) and a result in Javascript in about 4 sec, because it happens in my computer and there is no time out. It looks like the problem is really in the regEx itself. I'll try to get another one. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359391 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Why this regex takes so long?
Think this has something to do with the Regex itself. I stink at them; however try plugging it in here: http://regex101.com/ It returns something about catastrophic backtracking. You may want something like this: [A-Z0-9]*@ On Thu, Oct 2, 2014 at 11:51 AM, <> wrote: > > Hi, I'm having a problem with a scheduled task that chokes my server. > Its role is to analyse bounced messages. > I have been able to identify where it blocks, when analysing a line like > this one with the regex below: > "Message-id: <26823262.22036.1411993378646.JavaMail.NS4007563$@127.0.0.1>" > "[A-Za-z0-9_](\.?[A-Za-z0-9_\-]+)*@[A-Za-z0-9_\-\.]+(\.[A-Za-z]{2,6})"> > The server seems to get stuck in an infinite loop. > Actually, the problem is that the function REfind takes much too long. > > I narrowed the problem to the following code which shows that the time > taken grows exponentially with the number of characters and is anyway > abnormaly long : > > > > > > > > > >line = (#len(line)# char. = #line# >result = #result# in #time# sec. > > > And the result is: > line = (17 char. = 000$@ result = 17 in 0.055 sec. > line = (18 char. = $@ result = 18 in 0.028 sec. > line = (19 char. = 0$@ result = 19 in 0.063 sec. > line = (20 char. = 00$@ result = 20 in 0.113 sec. > line = (21 char. = 000$@ result = 21 in 0.224 sec. > line = (22 char. = $@ result = 22 in 0.447 sec. > line = (23 char. = 0$@ result = 23 in 0.902 sec. > line = (24 char. = 00$@ result = 24 in 1.787 sec. > line = (25 char. = 000$@ result = 25 in 3.574 sec. > line = (26 char. = $@ result = 26 in 7.192 sec. > > > ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359390 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Why this regex takes so long?
Hi, I'm having a problem with a scheduled task that chokes my server. Its role is to analyse bounced messages. I have been able to identify where it blocks, when analysing a line like this one with the regex below: "Message-id: <26823262.22036.1411993378646.JavaMail.NS4007563$@127.0.0.1>" The server seems to get stuck in an infinite loop. Actually, the problem is that the function REfind takes much too long. I narrowed the problem to the following code which shows that the time taken grows exponentially with the number of characters and is anyway abnormaly long : line = (#len(line)# char. = #line# result = #result# in #time# sec. And the result is: line = (17 char. = 000$@ result = 17 in 0.055 sec. line = (18 char. = $@ result = 18 in 0.028 sec. line = (19 char. = 0$@ result = 19 in 0.063 sec. line = (20 char. = 00$@ result = 20 in 0.113 sec. line = (21 char. = 000$@ result = 21 in 0.224 sec. line = (22 char. = $@ result = 22 in 0.447 sec. line = (23 char. = 0$@ result = 23 in 0.902 sec. line = (24 char. = 00$@ result = 24 in 1.787 sec. line = (25 char. = 000$@ result = 25 in 3.574 sec. line = (26 char. = $@ result = 26 in 7.192 sec. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359388 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm