Surround certain string with specified characters using regex-capable editor

1

I need to format certain string in Sphinx's documentation H2 Header.

Example:

v-add-user should be replaced with

********* v-add-user *********

I search for needed string in Notepad++ (regex ^(v-.*)) and replace it with

********$0********

in order to achieve the desired.

Current solution is pretty gruesome. Is there any way to optimize and simplify current solution or get another one, using Notepad++, sed, vim or any kind of software capable to perform such conversion? It also would be great if number of asterisks in the string-wrapper corresponds to the length of string being wrapped.

Twissell

Posted 2019-05-05T18:21:14.153

Reputation: 33

Answers

0

I don't find any compact solution, so I prefer to use sed to process sources.

I treat all of the matched strings with the following command.

sed -ri 's/^(v-.*)$/******\n\1\n******/' output.rst

It satisfies my needs for now.

Twissell

Posted 2019-05-05T18:21:14.153

Reputation: 33