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

Re: Simple regular expression not doing what I think it should

Expand Messages
  • mycroft_b
    ... of ... a ... especially ... Light ... pattern.) ... Wow. Figures a relative beginner would bump into something like that. Thanks for the replies.
    Message 1 of 6 , Oct 18, 2008
    • 0 Attachment
      --- In notetab@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
      >
      > --- In notetab@yahoogroups.com, "Sheri" <silvermoonwoman@> wrote:
      > >
      > > --- In notetab@yahoogroups.com, "mycroft_b" <mycroft_b@> wrote:
      >
      > > > I thought the caret (^) matches at the beginning of a line so I
      > > > thought the reg expression ^\^ would only match a caret at the
      > > > beginning of a line.
      > > >
      > > > Why does it match ALL carets (one at a time) in the following
      > > > text? What should my expression be?
      >
      > The regex engine used by NoteTab, PCRE, can match at the beginning
      of
      > the subject text as well as at the beginning of internal lines. When
      > you Find one match at a time, after a hit, the beginning of a NEW
      > subject is at the next character. Usually that is fine, because the
      > next character doesn't match the rest of the pattern.
      >
      > Maybe what you want to do is match not only the starting caret in
      > column one in your text, but the rest of the line as well:
      >
      > ^\^.*
      >
      > Then on the next execution, it won't be anchored at the start of a
      > possible unwanted match.
      >
      > NoteTab Pro has done something to defeat the matching behavior when
      a
      > pattern begins with a caret. It moves the cursor to the beginning of
      > the next line before using PCRE. That causes problems too,
      especially
      > if you are trying to search in highlighted text and don't want the
      > cursor moved when there is no match. So I prefer the way NoteTab
      Light
      > and Standard work (although you can get around the NoteTab Pro "fix"
      > by putting a (?#comment) in front of the leading caret in the
      pattern.)
      >
      > In other operations, like replacing all occurrences, NoteTab treats
      > the whole document as the subject. I believe it is only when using
      > Find that there's an issue.
      >
      > Regards,
      > Sheri
      >

      Wow. Figures a relative beginner would bump into something like that.
      Thanks for the replies. (?<=\r\n)\^ works the best because I am doing
      more than what you know... I simplified my question and ^\^.* matches
      the entire line which I didn't want (but you didn't know). It's a
      good little example of lookbehind assertions which I have never used.

      So it seems to me it really WASN'T working according to the
      documentation for whatever reason. Regular expressions are an
      amazingly powerful search feature and I'm new to it to.

      Thanks for the help.
    Your message has been successfully submitted and would be delivered to recipients shortly.