Author Topic: Slick hang in perl RE search  (Read 2311 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Slick hang in perl RE search
« on: August 29, 2017, 11:58:29 PM »
In the regex tool I was playing with a regex to match a path.
Open the attached TXT file.
In Find, do a Perl RE search in that file with this pattern
([a-zA-Z]:)?([\\/]*[^\r\n<>:"\\/|?*]+)+[\\/]?\(([0-9]+)\):
And slick hangs.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6862
  • Hero Points: 528
Re: Slick hang in perl RE search
« Reply #1 on: August 31, 2017, 02:39:52 PM »
Reproduced. Thanks for the small sample

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6862
  • Hero Points: 528
Re: Slick hang in perl RE search
« Reply #2 on: August 31, 2017, 03:16:12 PM »
It turns out that this is a really slow regex. If you let it run for a very long time, it will finish. On my machine (pretty fast windows machine), it takes about 62 seconds to finish.

If I hold down Ctrl+Alt+Shift+F2, the search is cancelled.

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: Slick hang in perl RE search
« Reply #3 on: August 31, 2017, 04:35:33 PM »
Thanks.
Can you give any advice on why it is so slow and how to improve it?
I tried a number of things, but it seemed that as I made changes it would go from being quick to being *really* slow - not a lot of in between.

I tried replacing "+" with "+?" and "++". Especially with ++ I expected it to make a perf difference.


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6862
  • Hero Points: 528
Re: Slick hang in perl RE search
« Reply #4 on: August 31, 2017, 10:13:39 PM »
Without spending too much time on it I tried this:

([a-zA-Z]:)?+([\\/]*+[^\r\n<>:"\\/|?*]++)+:

I got rid of most of the backtracking. I'm not sure what you were trying to accomplish with the regex stuff after what I used.