Re: [code] [textadept] Search and replace by regex

From: Procházka Lukáš Ing. <LPr.att.pontex.cz>
Date: Fri, 31 Jan 2020 17:06:42 +0100

Hi Michell,

On Fri, 31 Jan 2020 16:47:36 +0100, Mitchell <m.att.foicica.com> wrote:

> Hi Lukas,
>
> On Fri, 31 Jan 2020, Procházka Lukáš Ing. wrote:
>
>> Hello,
>>
>> suppose having buffer with:
>>
>> ----
>> abcd v ghij
>> abcd v ghij
>> abcd v ghij
>> ----
>>
>> and regex to be found: " ([v]) +(%w)"
>>
>> TA (10.8) doesn't find anything, although IMHO it should do (should be " v g"
>> three times).
>>
>> What am I doing wrong?
>
> Try \w instead of %w. I mix up regex with Lua patterns all the time :)

OK - so TA regex engine is Lua? With substitution '\' for '%' at any place of usage?

Lua uses '%' to prefix character class:

        https://www.lua.org/manual/5.3/manual.html#6.4.1

And search and replace in TA to be written using '\' instead of '%', so e.g.:

        search: " ([v]) +(\w)"
        replace: " \1~\2"

will change "abcd v ghij" to "abcd v~ghij"?

Is '%' -> '\' the only difference for Lua regex syntax?

Best regards,

Lukas

> Cheers,
> Mitchell

-- 
Ing. Lukáš Procházka | mailto:LPr.att.pontex.cz
Pontex s. r. o.      | mailto:pontex@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn
Bezová 1658
147 14 Praha 4
Mob.: +420 702 033 396
-- 
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 31 Jan 2020 - 11:06:42 EST

This archive was generated by hypermail 2.2.0 : Sat 01 Feb 2020 - 06:52:02 EST