Loading ...
Sorry, an error occurred while loading the content.
 

Re: Searching text for large list of keywords - how best?

Expand Messages
  • hugo_paulissen
    ... Theo, I m not sure if this is what you are after but you could try it with something like: n* w*(example1)|(example2)|(example3)|(example4) Apparently
    Message 1 of 7 , Sep 30, 2003
      > <quote>
      > Find=(example1)|(example2)|(example3)|( example4)
      > Replace=new value1
      > </quote>
      > If I copy the whole of this message into Note Tab Light,
      > click on Search:Find:,
      > set regexp,
      > paste this string -
      > \w(expr)|(replace)|(example)
      > - into the Reg. expr: field in the Find box,
      > and press Find Next repeatedly, the find gets stuck
      > on a match where the matched text includes a trailing
      > blank on the previous line.
      >
      > Is this a bug or a feature? ;)
      > (PS is there a workround?)


      Theo,

      I'm not sure if this is what you are after but you could try it with
      something like:

      \n*\w*(example1)|(example2)|(example3)|(example4)

      Apparently your construction with "\w(expr)|etc" chokes on the
      trailing blank/new line character. Please note that the Regular
      Expression-engine may cause hickups if you construct complex
      expressions. It is always safe to make a backup first.

      Hugo
    • Theo Brueton
      At 21:10 30/09/03 -0000, hugo_paulissen wrote: I m not sure if this is what you are after but you could try it with ... Interesting! A string in the form
      Message 2 of 7 , Oct 1, 2003
        At 21:10 30/09/03 -0000, hugo_paulissen wrote:
        I'm not sure if this is what you are after but you could try it with
        >something like:
        >
        >\n*\w*(example1)|(example2)|(example3)|(example4)
        >
        >Apparently your construction with "\w(expr)|etc" chokes on the
        >trailing blank/new line character.

        Interesting!

        A string in the form following your suggestion, ie
        \n*\w*(expr)|(replace)|(example)
        doesn't "choke"; but it only finds matches occurring at the start
        of a line. Thus it seems that the * (match 0 or more) doesn't
        work as advertised here!

        However,
        ((\n)|(\w))(expr)|(replace)|(example)
        seems to produce the result I am looking for!

        (I don't understand the need for
        the inner brackets in ((\n)|(\w)) ]

        So, thank you very much Hugo!

        >Please note that the Regular
        >Expression-engine may cause hickups if you construct complex
        >expressions.

        Oh dear, is this a regular "feature"?

        I'm not sure that the expression I'm after is/should really be
        complex - I'm just trying to find matches with a list of keywords.
        (But unless you put a \w or similar at the beginning you'll generally get
        "false" matches, where a keyword forms part of a longer word)

        >It is always safe to make a backup first.

        Indeed.

        Regards, Theo
      Your message has been successfully submitted and would be delivered to recipients shortly.