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

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

Expand Messages
  • flo.gehrke
    Feb 25 6:13 AM
    • 0 Attachment
      --- In notetab@yahoogroups.com, "Eb" <ebbtidalflats@...> wrote:
      >
      > Ahhh!
      >
      > The two (or more) spaces pose a problem. Many computer algorithms
      > interpret multiple spaces as one. NoteTab is confused here. Part
      > of the regex engine sees the first space individually, but another
      > part interprets the two spaces as one. Since that second part does
      > not have a space left in the target string, it cannot match the
      > string.

      There is no "interpreting the two spaces as one" here. NT is exactly following PCRE rules: The Lookbehind is matching the first space after 'word1', and the Character Class '[^\r\n]' matches the second space following 'word1'.

      As you wrote, you just have to remove the spaces from both Assertions in order to include all spaces into the match.

      Regards,
      Flo





      >
      >
      > The easy solution is to include one or more spaces in your match.
      >
      > If you're ok with including the space in the matches pattern,
      > i.e. " some text here ", just eliminate the space from the assertion (anchors), and use "(?<=word1)[^\r\n]*(?=word2)". Or "(?<=word1).*(?=word2)"
      >
      > To eliminate a variable size of white space from the match is very tricky without replacing the original text. Better would be to include 1 space in the assertion, and include any remaining spaces in the matched pattern.
      >
      > i.e. "(?<=word1 ) *[^\r\n]* *(?= word2)"
      > The space followed by an asterisk will allow for zero or more spaces.
      >
      >
      > Eb
      >
      >
      > --- In notetab@yahoogroups.com, "book7reader" <jim@> wrote:
      > >
      > > If this is the actual target text:
      > >
      > > word1 some text here word2
      > >
      > > And I paste in:
      > >
      > > (?<=word1 )[^\r\n]*(?= word2)
      > >
      > > ...and click the Notetabpro Regular Expression check box in Find,
      > >
      > > It does not find " some text here "
      > >
      > > ?????
      > >
      > > James
      > >
      >
    • Show all 15 messages in this topic