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

Re: [NTB] Stripping text up to a given character

Expand Messages
  • Don - HtmlFixIt.com
    Interesting. If I have a three pattern search, can I disable the capture one by one? So if I have (one)(two)(three) and then I only want to capture one and
    Message 1 of 5 , Jun 7, 2009
    View Source
    • 0 Attachment
      Interesting. If I have a three pattern search, can I disable the
      capture one by one?

      So if I have (one)(two)(three) and then I only want to capture one and
      three I could go (one)(?:two)(three).

      Which if I put the three repeat as you did ... in the middle
      (one)(?:two){3}(three) would avoid the unnecessary capture?

      Notice I took this off of the notetab list and dumped it in clips ...
      maybe should have gone off topic? Is regex on or off topic? :-)

      Sheri wrote:
      > --- In notetab@yahoogroups.com, "Don - HtmlFixIt.com" <don@...> wrote:
      >> true ... exactly the kind of thing a sample would show I guess
      >> ... early in the morning I like your middle one -- repeat same
      >> time 3 very efficient ... I don't quite get the last one however
      >> ... what does that ?: (at least I think it's a questionmark
      >> colon) do?
      >
      > Normally the parenthesized part of the pattern would be captured, in this case as $1. Question mark colon says don't bother to capture. Its more efficent to disable the capture when unused, and in this case (because the repetition) the capture would be useless anyway. Without the question mark colon, $1 would exist but it would contain only the last of the three matches of .*?_
      >
      > Regards,
      > Sheri
      >
    • Sheri
      ... LOL, Per our charter: We hope to use the regular list for basic NoteTab How to questions and other NoteTab assistance in general. The NoteTab Clips List
      Message 2 of 5 , Jun 7, 2009
      View Source
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "Don - HtmlFixIt.com" <don@...> wrote:
        >
        > Interesting. If I have a three pattern search, can I disable the
        > capture one by one?
        >
        > So if I have (one)(two)(three) and then I only want to capture
        > one and three I could go (one)(?:two)(three).
        >
        > Which if I put the three repeat as you did ... in the middle
        > (one)(?:two){3}(three) would avoid the unnecessary capture?
        >
        > Notice I took this off of the notetab list and dumped it in clips
        > ...
        > maybe should have gone off topic? Is regex on or off topic? :-)

        LOL, Per our charter: "We hope to use the regular list for basic NoteTab "How to" questions and other NoteTab assistance in general. The NoteTab Clips List is to be used for the Clips and more advanced topics like RegExp."

        So Thanks to Jody, Regex is ontopic here :D

        I'm not sure I understand your question, but any time you use ?: for a group, it causes that group to be non-capturing. You must then skip that set of parentheses for counting groups to retrieve by number. So if you have:

        (one)(?:two){3}(three)

        where matched, "one" would be in $1 and "three" would be in $2.

        Regards,
        Sheri
      • Don - HtmlFixIt.com
        Yes that answers my question. I didn t know if once invoked it followed or continued invoked or if you did it one at a time, etc. I also might have still
        Message 3 of 5 , Jun 7, 2009
        View Source
        • 0 Attachment
          Yes that answers my question. I didn't know if once invoked it
          "followed" or continued invoked or if you did it one at a time, etc. I
          also might have still called "three" $3 or maybe $5 because the middle
          one took up three places. Cleared up a lot of questions. As always,
          thanks.

          Don

          Sheri wrote:
          > --- In ntb-clips@yahoogroups.com, "Don - HtmlFixIt.com" <don@...> wrote:
          >> Interesting. If I have a three pattern search, can I disable the
          >> capture one by one?
          >>
          >> So if I have (one)(two)(three) and then I only want to capture
          >> one and three I could go (one)(?:two)(three).
          >>
          >> Which if I put the three repeat as you did ... in the middle
          >> (one)(?:two){3}(three) would avoid the unnecessary capture?
          >>
          >> Notice I took this off of the notetab list and dumped it in clips
          >> ...
          >> maybe should have gone off topic? Is regex on or off topic? :-)
          >
          > LOL, Per our charter: "We hope to use the regular list for basic NoteTab "How to" questions and other NoteTab assistance in general. The NoteTab Clips List is to be used for the Clips and more advanced topics like RegExp."
          >
          > So Thanks to Jody, Regex is ontopic here :D
          >
          > I'm not sure I understand your question, but any time you use ?: for a group, it causes that group to be non-capturing. You must then skip that set of parentheses for counting groups to retrieve by number. So if you have:
          >
          > (one)(?:two){3}(three)
          >
          > where matched, "one" would be in $1 and "three" would be in $2.
          >
          > Regards,
          > Sheri
        • ebbtidalflats
          ... Thanks for clearing that up. One question remains. Does this carry into a nested parentesis? Would (one)(?:two(four)){3}(three) bring the same result as in
          Message 4 of 5 , Jun 7, 2009
          View Source
          • 0 Attachment
            --- In ntb-clips@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
            >
            > I'm not sure I understand your question, but any time you use ?: for a group, it causes that group to be non-capturing. You must then skip that set of parentheses for counting groups to retrieve by number. So if you have:
            >
            > (one)(?:two){3}(three)
            >
            > where matched, "one" would be in $1 and "three" would be in $2.


            Thanks for clearing that up. One question remains. Does this carry into a nested parentesis?


            Would (one)(?:two(four)){3}(three) bring the same result as in your above example?


            TIA


            Eb
          • Sheri
            ... You would need ?: in the (four) group to avoid capturing it. Because it is inside a repeating group, it is useless when captured imo. (four) would be in $2
            Message 5 of 5 , Jun 7, 2009
            View Source
            • 0 Attachment
              --- In ntb-clips@yahoogroups.com, "ebbtidalflats" <ebbtidalflats@...> wrote:
              >
              > --- In ntb-clips@yahoogroups.com, "Sheri" <silvermoonwoman@> wrote:
              > >
              > > I'm not sure I understand your question, but any time you use ?: for a group, it causes that group to be non-capturing. You must then skip that set of parentheses for counting groups to retrieve by number. So if you have:
              > >
              > > (one)(?:two){3}(three)
              > >
              > > where matched, "one" would be in $1 and "three" would be in $2.
              >
              >
              > Thanks for clearing that up. One question remains. Does this carry into a nested parentesis?
              >
              >
              > Would (one)(?:two(four)){3}(three) bring the same result as in your above example?
              >
              >
              > TIA
              >
              >
              > Eb
              >

              You would need ?: in the (four) group to avoid capturing it. Because it is inside a repeating group, it is useless when captured imo. (four) would be in $2 and would contain the last "four" in the third occurrence of twofour in:

              onetwofourtwofourtwofourthree

              You can test it by running
              ^!Replace "(one)(?:two(four)){3}(three)" >> "*$2*" RSA2

              against document text:
              onetwofourtwofourtwofourthree
              onetwofourtwofourtwofourthree
              onetwofourtwofourtwofourthree

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