Resource icon

Post Content Find / Replace 1.0.0

No permission to download
Thanks but if possible I'd rather do this via the addon as it's a lot safer since that way I can narrow it down and test beforehand as well. I'm not really comfortable running any such queries without prior testing and I don't have a test install available right now.
 
I've made over 50.000 replacements of pretty much anything you can think of in the last couple of weeks and cleaned up nearly 20 years worth of posts, which had everything from smilies, html to various importing issues and broken tags. Literally the only thing that I've found no way whatsoever to replace with this addon are <br> tags.

Given how incredibly useful this tool is, is there any chance that you could add support for replacing line breaks to it as well, @Kier ? Everyone cleaning up html that XF doesn't allow (=converting it to bbCode) will come across this issue and I've come to rely on PCFR for doing safe replacements, since the quick find field enables me to narrow it down as much as I like, performing test replacements on only a single or a handful of posts before doing a major mass replace. It really is the only relatively safe way to do replacements on a large scale.
 
I have a couple of easy ones. These are "hanging chads" from a conversion that I never caught and never got back to.

I have the following instances of code related to old animated smilies

This one is a broken path (not a full URL)
Code:
/DesktopModules/ActiveForums/themes/_default/emoticons/biggrin.gif

This one is the full IMG code link
Code:
[IMG]http://www.myforum.org/DesktopModules/ActiveForums/themes/_default/emoticons/whistling.gif[/IMG]

and I need to change these to
Code:
[IMG]http://www.myforum.org/data/emoticons/whistling.gif[/IMG]

The filename is not relevant, it's only this
Code:
/DesktopModules/ActiveForums/themes/_default/emoticons
that needs to change to this
Code:
/data/emoticons

It's easy to fix with
Quick
Code:
emoticons
Reg
Code:
/\/DesktopModules\/ActiveForums\/themes\/_default\/emoticons/i
repl
Code:
/data/emoticons

But that also catches the "broken" ones in a way that makes them difficult to then pinpoint - i.e. I have to look for /data/emoticons that is not part of a larger URL.

So I figure if I first fix the full URLs, all that will be left will be the broken ones.

I need the regex then for matching this
Code:
[IMG]http://www.myforum.org/DesktopModules/ActiveForums/themes/_default/emoticons/ABCDEFG.gif[/IMG]
and changing it to this
Code:
[IMG]http://www.myforum.org/data/emoticons/ABCDEFG.gif[/IMG]
where ABCDEFG is one of many .gif filenames like sad, biggrin, wink, angry, cry, blink, rolleyes, etc.

Which I THINK is this
Code:
(\[IMG\]http:\/\/www\.myforum\.org)\/DesktopModules\/ActiveForums\/themes\/_default\/emoticons(\/[\w\-]+\.gif\[\/IMG\])
and sub this
Code:
\1/data/emoticons\2
 
Follow-up...worked like a charm. I've ferreted out about 20 different iterations of how the old software linked to old smilies, getting good at the regex again....made over 6000 corrections on my test site
 
So I have a tricky one I can't quite figure out.

I have several hangers that didn't get the leading URL tacked on, like this

Code:
/Portals/0/activeforums_Attach/IMG_0171.JPG

That directory exists, so I want to just change the above to this

Code:
https://www.mysite.org/Portals/0/activeforums_Attach/IMG_0171.JPG

The problem is, there are also links that exist properly, so if I try this REGEX
Code:
/(\/Portals\/0\/activeforums_Attach\/[0-9a-zA-Z_]+\.[a-z]+)/i

and this replacement
Code:
https://www.mysite.org\1

I'll double-up all of the leading URLs on the ones that are already correct. I can fix that with a secondary find/replace for the double URL, but is there a way to exclude the already correct URLs from the regex?
 
I need help to replace imagehosting.org to imagehosting.cc to fix image problem on my forum which posted by members.
any help would be appreciated. thank you in advance.
 
I need help to replace imagehosting.org to imagehosting.cc to fix image problem on my forum which posted by members.
any help would be appreciated. thank you in advance.
Have you tried using the image in the Overview as a template, replacing "org" with "cc"? If I remember right, there's a "s20" in the links that needs to be kept as part of the address for it to work right.
 
Have you tried using the image in the Overview as a template, replacing "org" with "cc"? If I remember right, there's a "s20" in the links that needs to be kept as part of the address for it to work right.

so, my users usually post image from postimage.org .
it can be manually changed to postimage.cc and image will be shown.
as for example:
Code:
[IMG]https://s26.postimg.org/fuc11mjih/A18907-2869867727.1493311674.jpg[/IMG]
to
Code:
[IMG]https://s26.postimg.cc/fuc11mjih/A18907-2869867727.1493311674.jpg[/IMG]

but it would take a long time to change them one by one.
can anyone help me how?
TIA
 
so, my users usually post image from postimage.org .
it can be manually changed to postimage.cc and image will be shown.
as for example:
Code:
[IMG]https://s26.postimg.org/fuc11mjih/A18907-2869867727.1493311674.jpg[/IMG]
to
Code:
[IMG]https://s26.postimg.cc/fuc11mjih/A18907-2869867727.1493311674.jpg[/IMG]

but it would take a long time to change them one by one.
can anyone help me how?
TIA
iOR1zzy.jpg
 
You need to escape the dot character, also I think he wants to change the TLD only so removing the sub-domain would be ideal.
I'm almost positive I did exactly the above to correct all the postimg links on my own site, which are all working fine now, but by all means feel free to give him all the info you think he needs to do it a better way. In either case, here's my obligatory disclaimer that I take no responsibility for anything that might go wrong. ;)
 
I'm almost positive I did exactly the above to correct all the postimg links on my own site, which are all working fine now, but by all means feel free to give him all the info you think he needs to do it a better way. In either case, here's my obligatory disclaimer that I take no responsibility for anything that might go wrong. ;)
It works because the period is equivalent to any character but it's not correct regex as you may have unintended consequences. You must always escape periods (and a bunch of other characters).
 
It works because the period is equivalent to any character but it's not correct regex as you may have unintended consequences. You must always escape periods (and a bunch of other characters).
Well, I confess to having no idea what the unintended consequences of changing the image links might have aside from them maybe no longer working (and they don't already), but maybe someone should tell him in plain English exactly what syntax he needs to do it correctly then, because I suspect that he might not find anything you're saying right now very clear.
 
Well, I confess to having no idea what the unintended consequences of changing the image links might have aside from them maybe no longer working (and they don't already), but maybe someone should tell him in plain English exactly what syntax he needs to do it correctly then, because I suspect that he might not find anything you're saying right now very clear.
I'm just referring to unintended consequences in using unescaped periods in general, not in particular to this request.

Escaping a character in regex means adding a backslash in front of it. s26\.postimg\.org

In using this tool and searching for the text it's irrelevant, just thought I'd explain what it means.
 
I'm just referring to unintended consequences in using unescaped periods in general, not in particular to this request.

Escaping a character in regex means adding a backslash in front of it. s26\.postimg\.org

In using this tool and searching for the text it's irrelevant, just thought I'd explain what it means.

That's cool. I don't claim to be a whiz when it comes to all this, but I actually do at least know what escaping a character means. I just had no idea why it was so important in this case. And the first guy was also recommending dropping part of the domain when I'd already said that, based on my own experience, keeping it as is was necessary for the links to work. So I just decided to leave it up to him to give the guy better help, but he didn't, and then you responded with more of the same talk about regex and escaping dots. Not that I'm upset with you or anyone else, I just wanted one of you to spell it out for the guy like you just did in this latest comment: helping him instead of correcting me. Hopefully he'll have figured it out by this point. :)
 
@imno007 thank you for helping me to solve my problem.
I think I know your point why you include s26; to make it specific and reduce load time.
but unfortunatelly, it always give me gateway time out. my forum has 25,529,990 messages btw.
time to make backup and do mysql query I guess.
thank you imno007! (y)
 
Top Bottom