I'm trying to do a find-replace (in Notepad++, but the specific tool may not matter) for certain entries in a document. The document has entries that look something like this:
==Some header==
* {{Tselect|Select an option}}
** This is an option.
*** '''Someone:''' The option will have some kind of response.
*** '''Someone else:''' Possibly even multiple lines of response.
** This is a different option.
*** {{Tact|This one has a different type of response, surrounded by brackets}}
In the above example, I only want to match ** This is an option.
and ** This is a different option.
, but none of the other lines.
Additionally, once I've captured that, I want to wrap the text (not the *
characters) with the following: {{Topt|The text}}
.
I would keep the same number of asterisks, and put the text following the asterisks inside of the {{Topt|
and }}
.
For example, I would turn ** This is an option.
into ** {{Topt|This is an option.}}
.
I've been fiddling with the regex in a regex tester, but it's matching either nothing or almost everything. I know it will need to start with ^(\*+)
so that it only matches start of lines that have an unlimited number of asterisks followed by a space and so that I can capture the exact number of *
characters, and it will need to end with $
so that it's confined to a single line.
What I'm struggling with is how I can exclude anything where the text either starts with something surrounded by three '
characters, and also anything surrounded by the {{
and }}
characters.
In case it's relevant, this is wiki-code syntax, and it's bulleted items that are slightly more indented at times.
^\*+ \K(?!{{|''').+$
{{Topt|$0}}
. matches newline
Explanation:
Replacement:
Screenshot (before):
Screenshot (after):