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

Re: [NTS] Re: regular expression to find anything up to two spaces in a row ...

Expand Messages
  • Axel Berger
    ... Yes, you re right and that s probably better than my ^!Find (?s)(.+?)( {2,}) RSTI1 but it has the same problem. Don specified ... which I took to mean
    Message 1 of 13 , Jun 21, 2011
    • 0 Attachment
      Eb wrote:
      > Actually, I would expect the assertion:
      > (?= )
      > to find a string ending in 2 spaces, without including the
      > two spaces in the match.

      Yes, you're right and that's probably better than my

      ^!Find "(?s)(.+?)( {2,})" RSTI1

      but it has the same problem. Don specified
      > everything and anything unless until I
      > encounter two spaces in a row ...
      which I took to mean the two spaces may or may not occur, as is usual
      when using negative classes. If they're certain to do, then things get
      much easier.

      Axel
    • Don
      Yes the two spaces are certain to occur :-) I am limited I supposed in my understanding so I didn t make the assumption you made. Now that you explain it like
      Message 2 of 13 , Jun 21, 2011
      • 0 Attachment
        Yes the two spaces are certain to occur :-)

        I am limited I supposed in my understanding so I didn't make the
        assumption you made. Now that you explain it like that I guess it makes
        sense. What I am trying to do is use two spaces as a delimiter in
        essence. I will actually be discarding the spaces as unnecessary in
        what I am doing.

        Off to look up (?= ) and see what it means.

        On 6/21/2011 7:54 PM, Axel Berger wrote:
        > Eb wrote:
        >> Actually, I would expect the assertion:
        >> (?= )
        >> to find a string ending in 2 spaces, without including the
        >> two spaces in the match.
        >
        > Yes, you're right and that's probably better than my
        >
        > ^!Find "(?s)(.+?)( {2,})" RSTI1
        >
        > but it has the same problem. Don specified
        >> everything and anything unless until I
        >> encounter two spaces in a row ...
        > which I took to mean the two spaces may or may not occur, as is usual
        > when using negative classes. If they're certain to do, then things get
        > much easier.
        >
        > Axel
        >
        >
        > ------------------------------------
        >
        > Fookes Software: http://www.fookes.com/
        > NoteTab website: http://www.notetab.com/
        > NoteTab Discussion Lists: http://www.notetab.com/groups.php
        >
        > ***
        > Yahoo! Groups Links
        >
        >
        >
        >
      • Don
        From Regex Buddy (my newest friend ...): Positive lookahead works just the same. q(?=u) matches a q that is followed by a u, without making the u part of the
        Message 3 of 13 , Jun 21, 2011
        • 0 Attachment
          From Regex Buddy (my newest friend ...):

          "Positive lookahead works just the same. q(?=u) matches a q that is
          followed by a u, without making the u part of the match. The positive
          lookahead construct is a pair of round brackets, with the opening
          bracket followed by a question mark and an equals sign. You can use any
          regular expression inside the lookahead. Any valid regular expression
          can be used inside the lookahead."

          If I understand correctly, I can then actually do this:
          (?=( ))
          and create a back-reference if I wish?

          Learning as I go here :-) and it's fun. Thanks Axel and Eb!


          On 6/21/2011 7:54 PM, Axel Berger wrote:
          > Eb wrote:
          >> Actually, I would expect the assertion:
          >> (?= )
          >> to find a string ending in 2 spaces, without including the
          >> two spaces in the match.
          >
          > Yes, you're right and that's probably better than my
          >
          > ^!Find "(?s)(.+?)( {2,})" RSTI1
          >
          > but it has the same problem. Don specified
          >> everything and anything unless until I
          >> encounter two spaces in a row ...
          > which I took to mean the two spaces may or may not occur, as is usual
          > when using negative classes. If they're certain to do, then things get
          > much easier.
          >
          > Axel
          >
          >
          > ------------------------------------
          >
          > Fookes Software: http://www.fookes.com/
          > NoteTab website: http://www.notetab.com/
          > NoteTab Discussion Lists: http://www.notetab.com/groups.php
          >
          > ***
          > Yahoo! Groups Links
          >
          >
          >
          >
        • John Shotsky
          [Off to look up (?= ) and see what it means.] I use it often. It is the inverse of K - which doesn t capture anything before, but it evaluates it. (?=), when
          Message 4 of 13 , Jun 21, 2011
          • 0 Attachment
            [Off to look up (?= ) and see what it means.]

            I use it often. It is the inverse of \K - which doesn't capture anything before, but it evaluates it. (?=), when used in
            a regex, is exactly the same, meaning anything that follows is not captured, but is evaluated.



            So, this:

            "this that"

            Run on:

            ^!Replace "this\x20\K(?=that)" >> "with\x20" ARSW

            Produces "this with that"

            Pretty handy for inserting something without any capturing.

            Regards,

            John



            From: ntb-scripts@yahoogroups.com [mailto:ntb-scripts@yahoogroups.com] On Behalf Of Don
            Sent: Tuesday, June 21, 2011 18:23
            To: ntb-scripts@yahoogroups.com
            Subject: Re: [NTS] Re: regular expression to find anything up to two spaces in a row ...





            Yes the two spaces are certain to occur :-)

            I am limited I supposed in my understanding so I didn't make the
            assumption you made. Now that you explain it like that I guess it makes
            sense. What I am trying to do is use two spaces as a delimiter in
            essence. I will actually be discarding the spaces as unnecessary in
            what I am doing.

            Off to look up (?= ) and see what it means.

            On 6/21/2011 7:54 PM, Axel Berger wrote:
            > Eb wrote:
            >> Actually, I would expect the assertion:
            >> (?= )
            >> to find a string ending in 2 spaces, without including the
            >> two spaces in the match.
            >
            > Yes, you're right and that's probably better than my
            >
            > ^!Find "(?s)(.+?)( {2,})" RSTI1
            >
            > but it has the same problem. Don specified
            >> everything and anything unless until I
            >> encounter two spaces in a row ...
            > which I took to mean the two spaces may or may not occur, as is usual
            > when using negative classes. If they're certain to do, then things get
            > much easier.
            >
            > Axel
            >
            >
            > ------------------------------------
            >
            > Fookes Software: http://www.fookes.com/
            > NoteTab website: http://www.notetab.com/
            > NoteTab Discussion Lists: http://www.notetab.com/groups.php
            >
            > ***
            > Yahoo! Groups Links
            >
            >
            >
            >





            [Non-text portions of this message have been removed]
          • Art Kocsis
            John, Not quite. Look ahead and look behind assertions are very useful, I agree but K and (?
            Message 5 of 13 , Jun 22, 2011
            • 0 Attachment
              John,

              Not quite. Look ahead and look behind assertions are very useful, I agree but
              \K and (?<=...) [the positive look behind assertion] are NOT EXACTLY the
              same. The big difference (and what makes \K so much better), is that the
              escape sequence \K allows variable length sub patterns whereas the positive/
              negative look ahead/look behind assertions all require fixed length sub
              patterns.

              Namaste', Art

              At 06/21/2011 19:12, John wrote:
              >[Off to look up (?= ) and see what it means.]
              >
              >I use it often. It is the inverse of \K - which doesn't capture anything
              >before, but it evaluates it.
              >(?=), when used in a regex, is exactly the same, meaning anything that
              >follows is not captured,
              > but is evaluated.
            Your message has been successfully submitted and would be delivered to recipients shortly.