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

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

Expand Messages
  • John Shotsky
    Jun 21, 2011
      [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.



      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]
    • Show all 13 messages in this topic