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

Re: [NTB] Regular Expression: find between two words

Expand Messages
  • Don
    I m not sure that s/he was looking for a clip and I m not sure that s/he is even a member of clips. This Thread is a bit advanced for the general group and
    Message 1 of 15 , Feb 29, 2012
    • 0 Attachment
      I'm not sure that s/he was looking for a clip and I'm not sure that s/he
      is even a member of clips. This Thread is a bit advanced for the
      general group and has been going both places ... I apologize for not
      knowing where to send it.

      You suggest this:
      (?=\x20word2\b)

      I think in addition to \b there you need to provide for end of file or
      return at the end of word2? Or are those included in \b? \b in help
      simply says: "word boundary (only ASCII letters recognized)."

      I learn a lot in these discussions so thanks to all participating.
    • flo.gehrke
      ... Eb, I take for granted that word1 and word2 are part of the string -- without it the RegEx makes no sense. Although a Lookaround doesn t consume any
      Message 2 of 15 , Feb 29, 2012
      • 0 Attachment
        --- In notetab@yahoogroups.com, "Eb" <ebbtidalflats@...> wrote:
        >
        > Flo,
        >
        > James reports, that the expression
        >
        > "(?<=word1 )[^\r\n]*(?= word2)"
        >
        > fails to find " some text here "
        > (containing a double space on the left.
        >
        > Tests on my PC confirm this bug.
        >
        > Are you saying, YOUR NoteTab succeeds in finding the pattern?

        Eb,

        I take for granted that 'word1' and 'word2' are part of the string -- without it the RegEx makes no sense. Although a Lookaround doesn't consume any character those substrings must be there, of course.

        So we have to test the RegEx against...

        'word1 some text here word2'

        (two spaces after 'word1', one space preceding 'word2').

        As we've said before, after removing the spaces from the Assertions all characters between 'word1' and 'word2', including all spaces, are matched with '(?<=word1)[^\r\n]*(?=word2)'. This is - if I did'nt misunderstand him - what James aimed at, isn't it?

        For me, this is valid for NT 6.2 Pro / Win XP.

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