Author Topic: How to search for lines that have two elements in them ?  (Read 4109 times)

mbmcf

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
How to search for lines that have two elements in them ?
« on: February 05, 2010, 03:54:28 AM »
Hi All,

I searched for this but did not come up with any answers, please excuse me if the question has been answered previously.

I need to find lines of code that have two different items in them, but I don't want to see lines that have just the first term or lines that have just the second. Specifically, i need to find all lines that have the word 'remove' in them that also have the string 'next' in that line. I read the help doc & didn't see any way to do it.

Has anyone here had to do this type of search, & if so, how did you do it ?

Thanks,
Bruce McFarland
 ???

Graeme

  • Senior Community Member
  • Posts: 2812
  • Hero Points: 347
Re: How to search for lines that have two elements in them ?
« Reply #1 on: February 05, 2010, 08:38:50 AM »
Hi

You can use a regular expression like this.

(^?*\bhello\b?*\bgood\b*?*$)|(^?*\bgood\b?*\bhello\b?*$)

This is a slickedit regular expression.  The | is an or operator so it matches lines that have hello before good or good before hello.  \b matches at a word boundary.  If \b doesn't quite work for you you can replace it with e.g. [~A-Za-z0-9_]* which matches zero or more characters that are not alphanumeric or underscore.  See the tools menu for "regex evaluator" to test a regular expression and see the help for regex details.

A slightly easier way is to search for all occurrences of remove, then right click in the search results and use "filter search results" to narrow down what you're searching for, however, you can't get "whole word only" with the filter thing unless you use a regular expression there.

Graeme

mbmcf

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: How to search for lines that have two elements in them ?
« Reply #2 on: February 11, 2010, 03:54:46 AM »
Thanks for the reply, I'll give it a try !