andybadwool
andybadwool

Reputation: 59

Regex to remove/replace characters before and after string in Notepad++

I would like to do this kind of mass replace:

From:

[tab=TEXT TO KEEP]

To:

[b]TEXT TO KEEP[/b]

Is it achievable? If too complicated, I would also be happy even without the [B][/B] tags.

Please note that [tab=TEXT TO KEEP] are included within blocks of text, so the "search" would need to start at [tab= stop at the first ].

I tried for over a hour searching tutorials but I couldn't come up with the right regex. Thank you so much to anyone who can help me with this!

Upvotes: 1

Views: 4452

Answers (1)

Jerry
Jerry

Reputation: 71538

You can try the following with the regular expression Search&Replace of Notepad++:

\[tab=([^\]]+)\]

Replace with:

[b]$1[/b]

([^\]]+) is a capture group and will match any character except closing square brackets. The captured part is stored in the first variable since it's the first capture group, hence $1

Upvotes: 1

Related Questions