I have a text file (.sql database) which containings these strings
[center:t1jrwz84]
[center:18gl5k7g]
[center:3tkgm3zz]
[center:1jrwz84d]
They appear in text file like this
Hello [center:t1jrwz84] everyone. How are[center:18gl5k7g]you today?
Glad to meet[center:3tkgm3zz] you. Thanks for[center:1jrwz84d] coming.
How to delete all strings by replace function of Editor Notepad++, Sublime, … with regex syntax?
I try this regex syntax in Notepad++
- Find what: [[center].*.[]]
- Replace with:
And this is the result
Hyou today?
Glad coming.
Of course this is wrong. It isn’t my target. My target is
Hello everyone. How are you today?
Glad to meet you. Thanks for coming.
PS: I want to delete theme because these are wrong bbcodes, html tags in the posts of smf forum database. I converted it from phpbb (center, right, justify, font, …) with custom bbcode and Almsamim WYSIWYG Editor. MySQL doesn’t support regex syntax in replace query, UDF addon is so complicated, so i have to do it with .sql file and Text Editor.
You need a non-greedy capture; the
.*needs to be qualified with a?to keep from swallowing everything up to the last ‘]’ on the line.Find:
\[center\:(.*?)\]and replace with nothing. Here I’ve also removed extraneous brackets and escaped the ‘[‘, ‘]’, and ‘:’ with backslashes.