Resource icon

Post Content Find / Replace 1.0.0

No permission to download
These should work for you.


Quick Find:
Code:
media=youtube

Regular expression:
Code:
#(\[media=youtube])?([a-z0-9_-]{11})(")(\[/media])(?:\[/url])?#siu

Replacement String:
Code:
\1\2\4


_______________________________________



Quick Find:
Code:
video=youtube

Regular expression:
Code:
#(?:\[video=youtube_share;([a-z0-9_-]{11})])(?:[^\[]+)(\[/media])#siu

Replacement String:
Code:
[media=youtube]\1\2


Congrats on your conversion.
 
Hi, is there a way to reverse my edits, I have messed up with my "replace in a post" and I need to fix it now, I dont have a backup :( but I see in Admin Log the "post replace" commands is there a way I can reverse these?

Thanks
 
Hi, is there a way to reverse my edits, I have messed up with my "replace in a post" and I need to fix it now, I dont have a backup :( but I see in Admin Log the "post replace" commands is there a way I can reverse these?

Thanks
Depending on what you changed you may or may not be able to fix it. Undoing it is something that is not happening though as the only thing that should be in your log about it is the expression you ran if anything.


You should always work with a backup/testboard when possible and always test replacements without saving first.


What were you changing? There is a chance it can be fixed pending what it is but there is no guarantees (which is why you always take a backup with stuff like this). Shoot me a convo msg with what you were trying to change and the expression you ran and I will let you know if it is a possibility to fix.
 
Thanks for the super fast response, you were quicker than my host, who havent replied to my ticket yet :(

Luckily I have a backup from a few days ago, but I dont want to load the whole thing, only reload the thread tables, fingers crossed I can do it, I was trying to change [MP3] to [av] but I think the brackets [] caused me some problems, because it seamed to replace every a and every v with [[av]] luckily I think this only happened to 82 posts in one specific forum, but because it has changed a and v, I dont think I can reverse the issue :( without messing up the spelling of each thread, so fingers crossed for the table reload, do you think its possible for me to drop the tread tables and reload from my db? I will post some of the affected code below, you can tell me if you think it can be reversed.

Thanks kindly for your time EQnoble :)

Code:
Once [av]g[av]in it w[av]s [av] ple[av]sure to be pl[av]ying on www.b[av]ssdri[av]e.com r[av]dio, th[av]nks for tuning in.

Heres the show for those who missed it, or w[av]nt to check the show out [av]g[av]in, some blinding tunes in here, inspir[av]tion[av]l times :thumb:

Stre[av]m: [[[av][av]]]http://www.itstooloud.com/b[av]ssdri[av]e/Tobes_[av]nd_Bor[av]t_B[av]ssdri[av]e_Aug2013.mp3[/[[av][av]]]

or right click [av]nd s[av][av]e [av]s to downlo[av]d:

http://www.itstooloud.com/b[av]ssdri[av]e/Tobes_[av]nd_Bor[av]t_B[av]ssdri[av]e_Aug2013.mp3

Tok[av]losh fe[av]t Lego - Another Le[av]el Soul Bros
D[av][av]e Owen - Smile For Me - Vibr[av]tion Records VR028 (out no[av] 5th)
Electrosoul System - Tr[av]ffic - KOSMOS 021
Bloke One & R[av]inforest - Delusion[av]l - C[av]dence Recordings 029
Vol[av]tile Psycle - B[av]rric[av]e - Terr[av]byte Recordings 08
Bloke One - On Letting Go - Vibr[av]tion Records VR030 (out Dec 5th)
*D[av][av]e Owen - Loose Lips (Heist Remix) Co L[av]b Recordings
*free downlo[av]d https://soundcloud.com/heist/d[av][av]e-owen-loose-lips-heist-remix
Roy Green & Protone - No Need For Worries - Kosmos 020
Ash Jeron[av] - In Your Eyes - VR033 (out Feb 25th 2014)
*Little Dr[av]gon - Twice (Insidem[av]n Bootleg Remix)
*free downlo[av]d http://www.[av]ibr[av]tionrecords.com/Little_Dr[av]gon_[av]s_Insidem[av]n_(Twice_VIP)_AIM_Insidem[av]nDnB.mp3.zip
Insidem[av]n - Inspired - Vibr[av]tion Records VR027 - Out 5th Oct
Bloke One & R[av]inforest - Sighs in Gloom - C[av]dence Recordings 029

Enjoy :z[av]berdust:
 
Ok, I reloaded xf_posts and all back to the way it should be, is there some detailed instructions for your addon so I make sure I dont make this mistake again, thanks kindly for your time :)
 
Oddly I replied to the last post but never clicked post reply :-/

Generally I need to see an example of what you want...find a post that has at least one instance of what you are trying to change click edit and use the bbcode editor view to get, copy and paste that example (not the whole post just a couple lines that contain what you are trying to change) into a code box and then also show the change you want.


This is important so I can give you an expression that will work.
 
Firstly, thanks so much for your help, if you have a donate button I would gladly donate a small sum to say thank you :)

I have just replaced the [ame links, but not all of them converted, Im not sure why, can you please help me change these to:

Code:
from:
[MP3]http://www.itstooloud.com/bassdrive/Bassdrive_Tobes2_January_2014.mp3[/MP3]
to:
[av]http://www.itstooloud.com/bassdrive/Bassdrive_Tobes2_January_2014.mp3[/av]

and from:
[ame="http://www.youtube.com/watch?v=DD-GYudGoAc"]Furney - Happy Alone - Soul Deep [SDE003] - YouTube[/ame]
to:
[media=youtube]DD-GYudGoAc[/media]

You can see here on this page not all the links converted, I wont play with anything without your advise as I was in a panic after breaking the forum last night :D
 
See if this works for you, make sure that you don't check save changes until after you have run it and check the results.

Code:
from:
[MP3]http://www.itstooloud.com/bassdrive/Bassdrive_Tobes2_January_2014.mp3[/MP3]
to:

Quick Find:
Code:
MP3

Regular expression:
Code:
#(\[)(/)?(mp3)(])#siu

Replacement String:
Code:
\1\2av\4



Code:
 from:
[ame="http://www.youtube.com/watch?v=DD-GYudGoAc"]Furney - Happy Alone - Soul Deep [SDE003] - YouTube[/ame]
to:
[media=youtube]DD-GYudGoAc[/media]

Quick Find:
Code:
ame

Regular expression:
Code:
#\[ame="http://(?:www.)?(youtube)[^=]+=([^"]+)"][a-z0-9\s-\[\]()]+\[/ame]#siu

Replacement String:
Code:
[media=\1]\2[/media]
 
Last edited:
You are a lifesaver, thats just sorted a load of links :) thanks so much :)

Only problem is some [ame= links are still visible, the replace code found 33 [ame links and changed them, but still I see some like this:

[CODE][ame="http://www.youtube.com/watch?v=i-xmVctae3k"]Change - Change Of Heart (Live 1984) - YouTube[/ame]

and like this

[ame]www.youtube.com/watch?v=NTFj8anEEqM[/ame][/CODE]

Basically I have a 108 page thread of "what are you listening to" I suppose some links are different to others and thats why they didn't all convert?

Thanks for being such a great help, I love Xenforo already :)

Tobes
 
Last edited:
You are a lifesaver, thats just sorted a load of links :) thanks so much :)

Only problem is some [ame= links are still visible, the replace code found 33 [ame links and changed them, but still I see some like this:

[CODE][ame="http://www.youtube.com/watch?v=i-xmVctae3k"]Change - Change Of Heart (Live 1984) - YouTube[/ame]

and like this

[ame]www.youtube.com/watch?v=NTFj8anEEqM[/ame][/CODE]

Basically I have a 108 page thread of "what are you listening to" here http://www.itstooloud.com/V5/threads/what-are-you-listening-to.7201/page-108 I suppose some links are different to others and thats why they didn't all convert?

Thanks for being such a great help, I love Xenforo already :)

Tobes
For the first one I have updated the expression that I had posted above. Rerun that one to catch the others that are similar...

the second one can't be caught by that expression because in the first we are matching ame= and in the second we are matching ame]


try this for the second example

Quick Find:
Code:
youtube


Regular expression:
Code:
#\[ame](?:www.)?youtube[^=]+=([a-z0-9_-]{11})\[/ame]#siu


Replacement String:
Code:
[media=youtube]\1[/media]
 
EQnoble you are a very kind and smart man, thank you so much, I think everything is perfect now, and thankfully all fixed, I will take another backup now so I don't have any more problems, as I said before do you have a paypal donate button, I am very happy to make a small gesture to say Thank You :)

Tobes
 
I've got images referenced at a CDN URL that is broken and I'd like the image URLs change to their local location.

The URLs are formatted:
Code:
http://eic.smartphoneresour.netdna-cdn.com/forum/data/MetaMirrorCache/i42.tinypic.com_as2sw.jpg

The image names differ, some are .jpg, .png .gif, but the URL prefix is the same.

The actual physical location of the images (using the above as an example):
Code:
http://forums.everythingicafe.com/data/MetaMirrorCache/i42.tinypic.com_as2sw.jpg

I'll defer to the experts, but it sounds like I need to replace:
http://eic.smartphoneresour.netdna-cdn.com/forum/

with

http://forums.everythingicafe.com/
 
Last edited:
Im trying to use this addon to first of all find all instances where the following URL is noted in my posts:
http://www.xyz.com/attachments/slide-jpg

It is causing an error for an addon that i have that is using attachments so want to find the offending posts, and then perhaps delete it.

Could someone please provide some assistance? :)
 
As a result of my own doing, moving my forums to a subdomain, I've got a few thousand broken images. I've been trying to recover from Google's Panda algorithm and quality of user experience is a big issue. I'm concerned about all the broken images.

Any help with the expressions for the above URL samples is greatly appreciated. This thread will give you an idea of how it's adversely affecting my site.

Thanks in advance.
 
I used a query courtesy of Jake to do simple replacements like this one. You could run this query to change the links.

Code:
UPDATE xf_post SET message = REPLACE(message, 'forum.emobucket.com','www.yabucket.com');

I wonder if this would work for me? @Jake Bunce

Code:
UPDATE xf_post SET message = REPLACE(message, 'eic.smartphoneresour.netdna-cdn.com/forum','forums.everythingicafe.com');
 

I did the mySQL query and it said it affected thousands of posts. However, it appears it doesn't touch the code within image embeds.

For example, I'm seeing the following still:

Code:
<img src="http://eic.smartphoneresour.netdna-cdn.com/forum/data/MetaMirrorCache/www.goodlookin.tv_news_zubaz_ful.jpg" class="bbCodeImage LbImage" alt="[IMG]" style="">
 
This is bizarre. If I inspect element, I see the old img src URL. If I click edit, the image immediately starts rendering from the new URL? If I save, it saves. If I click cancel, it reverts back. Is it possible that it's a caching issue? I've been rebuilding the assorted caches, in hopes that will fix it. Is there a specific cache?

I'm not sure if what I've done has fixed it completely, but it's caching or if I still need to do something more than the mySQL query?
 
Top Bottom