HowTo perform bracketed find and replace in Kate-based tools?

There are numerous variants on the problem, but a couple examples should suffice for an initial discussion.

Suppose the source document has
**this should be bold**
and I want to replace it with
\textbf{this should be bold}.

So I want to enter a regular expression that copies the content between the bracketing ** ... ** and replaces the entire string with \textbf{ ... }.

As a second example, I want to replace
### subsection title \n
with
\subsection*{subsection title} \n.

Are these doable using Kate?

This seems to work to match the pattern in question:

\*\*(.|((\*(?=\*\*))?|[^*]+|((?<=\*\*)\*)?|(?<!\*)\*(?!\*))+)\*\*

and replace with

\\textbf{\1}