Author Topic: Advanced search option  (Read 4902 times)

nudiv

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Advanced search option
« on: February 23, 2010, 07:42:41 AM »
Hi everyone,

I am looking for a way to implement the following advanced search option:
lets say I have the the phrase " HelloWorldFromNudiv" in my code. I don't know were is it exactly but I do know/remember the acronyms of it , which is  HWFN.
So my question is :
Is there any way to search the phrase by using the acronyms letters e.g. something like find: "H*W*F*N" or find: "H?W?F?N" .
Both ways didn't work .

Thanks in advance
Nadav
« Last Edit: February 23, 2010, 08:24:36 AM by nudiv »

kenkahn

  • Community Member
  • Posts: 33
  • Hero Points: 1
Re: Advanced search option
« Reply #1 on: February 23, 2010, 09:04:59 AM »
If you're working from a single source file enter the search

   /H.*[^W]W.*[^F]F.*[^N]N/ue

If you have multiple source files to search through use 'Search --> find in Files' and specify the same search string and options.

jimlangrunner

  • Senior Community Member
  • Posts: 360
  • Hero Points: 31
  • Jim Lang - always a student.
Re: Advanced search option
« Reply #2 on: February 23, 2010, 11:12:51 AM »
Just to expand on that - @kenkahn's string looks like a unix emulation search, which looks a little funny to someone who is used to SllckEdit emulation. I'm also not sure what the / or the "/ue" is for.  (Not that it matters - I assume it serves its purpose well).

I've found that Slick's "Regex Evaluator" Does a great job of helping me build regular expressions.  Yes, I ought to be able to rattle them off, but I cannot, so I use the tool.  The little arrow at the end of the expression line will insert just about anything.  So put your text in the Test Cases box and build the expression interactively.  It took me a while at first, but it does come pretty easy after getting used to it.  Right click in any toolbar to get the context list of toolbars available and it's in there.

Jim.

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Advanced search option
« Reply #3 on: February 23, 2010, 11:29:24 AM »
@nudiv -- Hi, the search string you suggested looks like a file system style wildcarded string where "*" means "match any characters".  Text editors typically support a much more powerful wildcard syntax called "regular expressions".  SlickEdit supports several different regular expression syntaxes -- you can find more information in the SlickEdit Help (look up "regular expressions").

A simple regular expression (Unix flavor) that seems to do what you're looking for is this:

H.*W.*F.*N

The "." means "match any 1 character".
The "*" means "match zero or more occurrences of the previous character, with maximal closure (as long of a match as possible)".
So ".*" means "match zero or more occurrences of any characters, with maximal closure".
And since your search string has several non-wildcard characters and you just wanted to search (versus e.g. performing search and replace), it ends up not mattering whether you use maximal closure or minimal closure.

nudiv

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: Advanced search option
« Reply #4 on: February 24, 2010, 11:35:39 AM »
Guys ,
Thank you very much!
It works well.

Nadav