Author Topic: Search Project for Regular Expression Hangs  (Read 183 times)

gsexton

  • Community Member
  • Posts: 18
  • Hero Points: 0
Search Project for Regular Expression Hangs
« on: November 28, 2017, 07:35:19 pm »
I tried running a Search, using Regular expressions on Linux using 22.0.0.9 with Hotfix 9 installed. My Search expression is:

\o:b*System\.out\(

The options were to search all files in the project.

When I execute the search, the SlickEdit UI hangs. Running top shows sgrep running 300% (3 cores). I let it run for 2 minutes before cancelling. The project has 38 PHP files in it.

The 0 or more (*) seems to be the trigger for a lockup.

If I turn on foreground search, the slickedit hangs.

jporkkahtc

  • Senior Community Member
  • Posts: 1425
  • Hero Points: 112
  • Text
Re: Search Project for Regular Expression Hangs
« Reply #1 on: November 29, 2017, 09:37:36 pm »
This is easy to repro, even searching a single buffer.

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1097
  • Hero Points: 94
Re: Search Project for Regular Expression Hangs
« Reply #2 on: November 29, 2017, 10:06:31 pm »
The \o:b has a builtin one or more qualifier (+), and the * adds another zero or more qualifier on top of that expression.  It does eventually finish, but the current regular expression engine is evaluating this in exponential time complexity.  I am filing a defect for this because it could definitely use some improvement. Preferably, you should just use [ \t]* for zero or more spaces, which is less complex expression.

gsexton

  • Community Member
  • Posts: 18
  • Hero Points: 0
Re: Search Project for Regular Expression Hangs
« Reply #3 on: November 29, 2017, 10:29:16 pm »
I guess that's the hazard of having your own regular expression dialect. Nobody understands it but you...

A routine thing that I do is search for:

DEBUG.*=\s*true;

In Slickedit, the \o:b won't work UNLESS there's a space. Plus when I select white space using the insertion dialog, how am I to know this subtlety? It really goes against the philosophy (that I understand) regular expressions by. I specify the character class, and how many times it shows up. I'll really have to train myself to specify my own character class [ \t]* to get the results I need. Having \o:b include an occurrence qualifier was just a bad idea.

I tested the expression in SE 2016, and it works as expected.

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1097
  • Hero Points: 94
Re: Search Project for Regular Expression Hangs
« Reply #4 on: November 30, 2017, 01:48:16 pm »
\o is a custom extension for the Perl compatible regex engine in SlickEdit.  In the help guide, it is documented that \o:b literally translates to (?:[ \t]+), one or more whitespace characters. I am filing a bug report to investigate it, as there is a performance difference in the two versions on how (?:[ \t]+)* works.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4031
  • Hero Points: 267
Re: Search Project for Regular Expression Hangs
« Reply #5 on: December 03, 2017, 02:48:42 pm »
:b was a very bad idea. Too late to fix it now. I'd recommend NEVER using it.