Re: [code] [textadept] Textadept 9 poll: Lua patterns or Regex?

From: Giovanni Salmeri <g.salmeri.att.mondodomani.org>
Date: Fri, 8 Jul 2016 16:05:08 +0200

> > On a side note: I modified the above script in order to allow
> > substitutions like s/^/x/g or s/$/x/g (for adding x at the
> > beginning or at the end of a line), which is something I consider
> > almost essential but that I have found rather tricky to implement.
> > Would the new solution you are proposing allow this?
>
> I'm not exactly sure, but I think you'd have to do something like
> "s/^./x\0/g" or "s/.$/\0x/g" (the \0 contains the entire match -- in
> this case the single character to keep).

Not exactly, because s/^/x/ matches also empty lines, while s/^./x\0/
does not. One could write s/^.?/x\0/ but the problem would remain:
for this to work in empty lines the replace command in Textadept should
handle correctly zero-length captures. Obviously, often s/^./x\0/ is
more desirable, but it is different (and when the effect would be the
same as s/^/x/ , it is a little more verbose...).

Same problem with \< and \> (but I think that a substitution
s/\</x/g is hardly useful).

> I think this would be something I'd put on the wiki as a possible
> extension, as it wouldn't be very hard to implement.

Great!

-- 
Giovanni Salmeri
http://mondodomani.org/pers/salmeri/
-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Fri 08 Jul 2016 - 10:05:08 EDT

This archive was generated by hypermail 2.2.0 : Sat 09 Jul 2016 - 06:29:04 EDT