Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Grep Search

Return to Member Forum

  • Author
    Posts
    • #55279

      How, in GREP, do you search for a string of specific words, in my case, the words “words in optional trims”. Needs to be a direct search so I can manipulate it in replace, rather than a look ahead look behind. Before this string is a number that varies and which I have no problem at all finding in a GREP search.

    • #55282
      Anonymous
      Inactive

      Do you want to find the just the “words in optional trims” before numbers? Or do you want to find all the numbers including the the text string?

      Can you give an example of what you want to find compared what you don't want to find?

    • #55284

      How, in GREP, do you search for a string of specific words?

      You type them :-) Without any lookahead/lookbehind or other GREP conditions, what you enter is what it'll search. (At least for regular text and digits — other symbols may need escaping, because they might be GREP instructions.)

      It appears you want to find (and mark) this text and only when it's preceded by a digit. Well, the digit can be taken care of with a lookbehind, and the rest is a “regular” find. Try this:

      (?<=d) words in optional trims

    • #55295

      Ok, here's exactly what I need to do. A string that looks like this:

      “with 209 words in option trims”

      Want to be able to replace so it reads: 209 wds. All the other words go away.

      The only thing that varies is the numeral… and I have no trouble finding it with Grep. But when I try to add the explicit words .. and I tried just typing them, I get a nothing found.

    • #55297
      Anonymous
      Inactive

      Find:

      withs+(d+)s+(w)or(ds) in option trims

      Change to:

      $1 $2$3

      with +(d+) +(w)or(ds) in option trims
    • #55306

      Thanks Eugene, that worked like a charm

      The main difference to what I had tried was the handling of the spaces around the search for the digits.

      Anyone willing to take a crack at this one. I just need to find it so I can replace it with nothing.

      EDS: EMBARGO: no web/TV until 2000 ET.

      There is a space preceding the EDS. The only thing that changes is the digits of the time, otherwise wouldn't need GREP. I've experimented, but my GREP rookie-ness is leaving me stumped. Do the colons need special handling? I realize the slash does.

      This forum's great. Thanks

    • #55313

      The slash doesn't :D Backslashes do, but the forward slash seems to be one of the handful non-alphanumerics that doesn't do anything. As far as I can tell, none of the characters in your sample need escaping.

      As with your “200 words” thingy, some of the spaces may have been entered as hard (non-breaking) spaces. Select “Show invisible characters” and check for these.

      You can also copy one of the lines and paste it into the Find what field of GREP — ID will convert any special characters to its GREP notation. It will not help if sometimes one space is entered as a hard space and on another occasion another space is, though.

      You can always change every single space in the string to s, which is a catch-all for “any sort of space at all”.

Viewing 6 reply threads
  • You must be logged in to reply to this topic.
Forum Ads