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

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

Expand Messages
  • Eb
    Feb 25, 2012

      Finding the last ocurrence is the default with regular expressions. If that is undesirable, follow the quantifier '*' with a question mark, i.e. "*?". Then it will find the first occurrence.

      If a match can occur multple times on the same line / paragraph, and you want to restrict the match, change the pattern

      from "(?<=Word1 )[^\r\n]*(?= Word2)"
      to "(?<=Word1 ).*?(?= Word2)"
      or "(?<=Word1 ) *.*? *(?= Word2)"


      --- In notetab@yahoogroups.com, "John Wallace" <johnta1@...> wrote:
      > What would it be if you wanted Word1 to the 1st occurance of the Word2?
      > It seems to go to the last occurrance of Word2 now.
      > John
    • Show all 15 messages in this topic