XF 2.2 regex for changing html headings to bbcode

djbaxter

in memoriam 1947-2022
Working on a forum where they used [H3]...[/H3]

Ran the Post content find / replace addon and converted all the [h3 to [heading=3

But now I'm trying to replace the closing tags and it's not working. I suspect it's the regex but I'm getting no specific errors.

closing h.webp

This fails to show anything. What's wrong with the entries? Specifically, what do I use as the regex here?
 
Untested, use at your own risk.

For opening brackets:

Quick find: [h
Regular expression: /\[h(\d)\]/i
Replacement string: [heading=$1]

For closing brackets:

Quick find: [/h
Regular expression: /\[\/h\d\]/i
Replacement string: [/heading]

This should replace the various headings simultaneously. Your original regular expression should work to replace only [/h2] tags if you simply escape the brackets and slash: /\[\/h2\]/i (the /i flag makes it case-insensitive).
 
Back
Top Bottom