Search/Replace capabilities of KATE 22.12.3
Richard Owlett
rowlett at access.net
Thu Feb 6 13:17:33 GMT 2025
On 2/4/25 4:34 AM, Rens Oliemans wrote:
> Hi Richard,
>
> Richard Owlett <rowlett at access.net> writes:
>
>> 2. Is there documentation (preferably a tutorial) for this?
>
> You already linked to the relevant documentation: The KatePart Handbook. The
> relevant section is "Appendix A. Regular Expressions":
>
> https://docs.kde.org/stable5/en/kate/katepart/regular-expressions.html
>
> Check especially the page on Patterns [0] and the "Capturing matching text (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
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.
>
>> I wish to write macros using ERE's[1] to make my project feasible.
>
> This is not possible:
Clarification:
I'm unsure of explicitly "This" refers to.
I've extremely little formal computer background -- a 1 semester "intro
to programming" as a freshman engineering student >60 years ago.
I've been a computer _user_ since the days of 12AX7 based CPU's,
Hollerith cards, and network connection via acoustic couplers ;}
I was referring to the general concept of an ERE, not an implementation.
>
> [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.
>
> -- https://docs.kde.org/stable5/en/kate/katepart/regular-expressions.html
>
> However, I believe that the syntax exposed is very similar and powerful enough.
>
>> 1. Does that discussion apply to Kate 22.12.3?
>
> 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.
>
> For an example of a regex replacement, I assume some basic knowledge about regex
> expressions (documentation can be found in the KatePart or elsewhere for similar
> regex syntaxes). If things are unclear, feel free to ask.
>
> Replacing the footnotes with uglier but easier clickable items. They were HTML
> <sup>[n]</sup> items, but the superscript makes them difficult to click on small
> screens. My goal:
>
> Convert
> 'Then the suitors came in and took their places on the benches and seats.<a href="#linknote-3" id="linknoteref-3" class="pginternal"><sup>[3]</sup></a> Forthwith men'
> with
> 'Then the suitors came in and took their places on the benches and seats.<a href="#linknote-3" id="linknoteref-3" class="pginternal">[3]</a> Forthwith men'
>
> Kate Replace:
> <sup>(\[\d+\])</sup> → \1
>
> Explanation: we find all <sup>...</sup> tags, and group the inner contents
> with a sub expression. Our replacement text is simply \1, which a reference to
> the first sub expression.
>
>
> [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
>
More information about the kde
mailing list