• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Post content replace help

Ingenious

Well-known member
#1
I'm trying to tidy up some very old posts over 10 years old, which were converted from Ikonboard to vB to Xenforo, but appear to contain HTML. So, the HTML appears in the actual post as plain text. Some of this is simple replace, like the </font> and <table> tags, plus some of the smilies (which were saved in the database as IMG BBCode). I can just find and remove these.

But some have the equivalent of wildcards, so wondering what to do, example:

Code:
<font color='#F660AB'>
The color being different with various posts.

I need to replace <font color=*> with ' ' (nothing).

The other one is the exotic smilies. I can do a simple search/replace, for example, find:

Code:
[IMG]http://www.my-forum-url/iB_html/non-cgi/emoticons/smile.gif[/IMG]
With:

Code:
:)
But for the remainder (all the odd smilies not covered by the basic ones in XF), I need to do the equivalent of finding and removing:

Code:
[IMG]http://www.my-forum-url/iB_html/non-cgi/emoticons/*[/IMG]

I guess I can run an update/replace MySQL command for the static ones via PHPMyAdmin but what about the wildcard ones? Any scripts out there which can do this for me? Alternatively, I can use Kier's post search/replace add-on, but I'd need someone to advise on the PCRE expressions to use please for the two examples above, as it's all Greek to me :)
 

Ingenious

Well-known member
#3
Thanks Jake. I don't need to replace font with colour, so what would I need to enter in those fields just to replace <font color=*> with nothing?

What does #siU mean?
 

Jake Bunce

XenForo moderator
Staff member
#4
Quick Find: [IMG]http://www.my-forum-url.com/iB_html/non-cgi/emoticons/

Regular Expression: #\[IMG\]http://www\.my-forum-url\.com/iB_html/non-cgi/emoticons/.*\[/IMG\]#siU

Replacement String: <nothing here, leave it empty>

That will completely remove all matching IMG tags.
 

Jake Bunce

XenForo moderator
Staff member
#5
Thanks Jake. I don't need to replace font with colour, so what would I need to enter in those fields just to replace <font color=*> with nothing?
Quick Find: <font

Regular Expression: #<font color='([^']+)'>(.*)</font>#siU

Replacement String: \2

That will leave only the text that was previously colored, but now it won't have any color tag.
 
#7
How can i replace links like this
Code:
[YT]http://www.youtube.com/watch?v=EBJ74xWl4fs[/YT]
with the xenforo code to see youtube video ?
I found these entries in old post, maybe they were generated by an old custom vbulletin plugin.
 
#11
thanks this worked ! Anyway a bug i faced one time during migration occured again. I dont' see the youtube video in post but if i edit the post i see the media code. If i simply click save and exit, the existing media code is embedded in another media code

Code:
[media=youtube][media=youtube]video url[/media][/media]
anyway i'll stick with this issue, not so important.
 

Jake Bunce

XenForo moderator
Staff member
#12
thanks this worked ! Anyway a bug i faced one time during migration occured again. I dont' see the youtube video in post but if i edit the post i see the media code. If i simply click save and exit, the existing media code is embedded in another media code

Code:
[media=youtube][media=youtube]video url[/media][/media]
anyway i'll stick with this issue, not so important.
The replacement might have been bad. I would need to see the original posting code in context to know for sure.
 

W1zzard

Well-known member
#13
Sorry for reviving such an old thread, the better regex to convert [yt tags is

Code:
#\[YT\]([A-Za-z0-9_\-]{11})\[/YT\]#siU
This ensures that only proper YT embeds with a YouTube ID in them get replaced, the regexp further up in the thread will replace everything, including people talking about the yt tag