Re: Search/Replace capabilities of KATE 22.12.3

Richard Owlett <[email protected]> Thu, 6 Feb 2025 07:17:33 -0600
Newsgroups gmane.comp.kde.general
Message-ID <[email protected]>
On 2/4/25 4:34 AM, Rens Oliemans wrote:
> Hi Richard,
>=20
> Richard Owlett <[email protected]> writes:
>=20
>>     2. Is there documentation (preferably a tutorial) for this?
>=20
> You already linked to the relevant documentation: The KatePart Handbook=
=2E The
> relevant section is "Appendix A. Regular Expressions":
>=20
>      https://docs.kde.org/stable5/en/kate/katepart/regular-expressions.=
html
>=20
> Check especially the page on Patterns [0] and the "Capturing matching t=
ext (back
> references)" paragraph: that paragraph is quoted in your stack overflow=
 link.

I think that is the key/solution to my problem.
You've given me a homework assignment.
Though I worked in Power Supply Engineering in the 70's, I was=20
surrounded by TECO fanatics. I suspect KATE is as powerful/flexible.


> It's rather concise for an examples/tutorial, but I'll an example below=
=2E
>=20
>> I wish to write macros using ERE's[1] to make my project feasible.
>=20
> This is not possible:

Clarification:
I'm unsure of explicitly "This" refers to.
I've extremely little formal computer background -- a 1 semester "intro=20
to programming" as a freshman engineering student >60 years ago.
I've been a computer _user_ since the days of 12AX7 based CPU's,=20
Hollerith cards, and network connection via acoustic couplers ;}

I was referring to the general concept of an ERE, not an implementation.

>=20
>      [The Appendix] documents regular expressions in the form available=
 within
>      KatePart, which is not compatible with the regular expressions of =
perl, nor
>      with those of for example grep.
>=20
>      -- https://docs.kde.org/stable5/en/kate/katepart/regular-expressio=
ns.html
>=20
> However, I believe that the syntax exposed is very similar and powerful=
 enough.
>=20
>>     1. Does that discussion apply to Kate 22.12.3?
>=20
> Unfortunately I cannot check this definitively since I don't have that =
version,
> but the Kate Handbook is written for Version 22.08, so it should.
>=20
> For an example of a regex replacement, I assume some basic knowledge ab=
out regex
> expressions (documentation can be found in the KatePart or elsewhere fo=
r similar
> regex syntaxes). If things are unclear, feel free to ask.
>=20
> Replacing the footnotes with uglier but easier clickable items. They we=
re HTML
> <sup>[n]</sup> items, but the superscript makes them difficult to click=
 on small
> screens. My goal:
>=20
> Convert
>    'Then the suitors came in and took their places on the benches and s=
eats.<a href=3D"#linknote-3" id=3D"linknoteref-3" class=3D"pginternal"><s=
up>[3]</sup></a> Forthwith men'
> with
>    'Then the suitors came in and took their places on the benches and s=
eats.<a href=3D"#linknote-3" id=3D"linknoteref-3" class=3D"pginternal">[3=
]</a> Forthwith men'
>=20
> Kate Replace:
>    <sup>(\[\d+\])</sup> =E2=86=92 \1
>=20
> Explanation: we find all <sup>...</sup> tags, and group the inner conte=
nts
> with a sub expression. Our replacement text is simply \1, which a refer=
ence to
> the first sub expression.
>   =20
>=20
> [0] https://docs.kde.org/stable5/en/kate/katepart/regex-patterns.html
> [1] https://gutenberg.org/ebooks/1727
        ^
        +--- *????* my post was:
        https://www.gnu.org/software/sed/manual/html_node/ERE-syntax.html=

>=20