Resource icon

Post Content Find / Replace 1.0.0

No permission to download
Something would always happen, be an error or a confirmation page or similar.

Can you describe the specific steps you took?

Yes, out of those three lines, the first went into Quick Find, the second into Regular Expression and the third into replacement String

I then click on Proceed (without save changes)


Absolutely nothing happens exceept URL changes:

Code:
From

http://test.cafesaxophone.com/admin.php?post-replace/

to:

http://test.cafesaxophone.com/admin.php?post-replace/replace
 
I was perhaps mistaken, I thought an error would be displayed if no results are found but I just tested this and if it doesn't find any content matching what you search for then it does effectively reload the page. If it does find something, what you should see is a list of posts that contain what you searched for, what the old text is and what the new text will be, like this:

upload_2016-9-13_14-24-4.webp

This is using one of your actual images in one of my posts and it seems to work.

At this point if I click Save Changes and Proceed, it will go ahead and make the changes:

upload_2016-9-13_14-25-41.webp
 
Thanks Chris, it seems it does work on my live forum though.

(My previous attempt was my test forum with recent import so URLs would be the same, odd)

Anyway all working now. Thanks.
 
Always best to place an actual working link (with domain name changed if you please) so we can test it before give you the correct search and replace strings.
 
Can someone please help:

After changing a username, would want to adjust the quotes and tags:

from:
Code:
[QUOTE="mark,
to:
Code:
[QUOTE="neee,


.................

and...

from:
Code:
[USER=5665]@mark[/USER]
to:
Code:
[USER=5665]@neee[/USER]


What do I need to fill in Quick Find, Regular Expression and Replacement String fields?

Thanks in advance!
 
After changing a username, would want to adjust the quotes and tags:

from:
Code:
[QUOTE="mark,
to:
Code:
[QUOTE="neee,
.................
Quick Find:
Code:
[quote="mark

Regex:
Code:
/[quote="mark(,|")/is

Replace:
Code:
[quote="neee\1

and...

from:
Code:
[USER=5665]@mark[/USER]
to:
Code:
[USER=5665]@neee[/USER]
Quick Find:
Code:
[USER=5665]@mark[/USER]

Regex:
Code:
/\[USER=5665]@mark\[\/USER]/is

Replace:
Code:
[USER=5665]@neee[/USER]

I threw this together quickly for you. I can't stress enough, please take a back up first and test the replacements first with the add-on before saving the changes (you should get a list of every post and how it will appear before and after). The second one is a bit basic but tags are 99% of the time auto generated so it should be adequate.
 
@ChrisD, what regex would be needed for a value that's constantly changing?

e.g I need to remove a bunch of Attach BBCodes, e.g
Code:
[ATTACH]1000[/ATTACH]

The 1000 will be a variable though

Assumably i can just find and pop the regex in the second field?


Edit: Never mind, I got it:

Code:
#\[ATTACH]([0-9a-z]+)\[\/ATTACH\]#siu
 
Last edited:
Quick Find:
Code:
[quote="mark
Regex:
Code:
/[quote="mark(,|")/is
Replace:
Code:
[quote="neee\1
Got the following error for the above, do you have a clue why?:

Server Error
preg_match_all(): Compilation failed: missing terminating ] for character class at offset 17

Quick Find:
Code:
[USER=5665]@mark[/USER]
Regex:
Code:
/\[USER=5665]@mark\[\/USER]/is
Replace:
Code:
[USER=5665]@neee[/USER]
The code for the second case, above, seems to work fine though, no errors thrown out.


Thanks Chris :love:
 
Heh, I tested the expression with an online tester and it didn't pick up on that.

Regex for the first case should be, then:
Code:
/\[quote="mark(,|")/is
(Everything else remains the same).
 
thanks to chris for telling me about this, it worked flawless

here is the code i used:


Code:
[IMG]http://mywebsite
#\[IMG]http://(mywebsite\.com/[^[]+)\[/IMG]#siu
[IMG]https://\1[/IMG]

&

Code:
[IMG]http://www.mywebsite
#\[IMG]http://www\.(mywebsite\.com/[^[]+)\[/IMG]#siu
[IMG]https://\1[/IMG]
 
@USERNAME

Yes, I don't believe @ users kicks an alert when included in an edit so you should be able to use this as normal.


Quick Find:
Code:
mention

Regular expression:
Code:
#((\[MENTION=)([0-9]+)(]))((?:.*?(?!\[/MENTION]?)).)(?:(\[/MENTION]))#siu

Replacement String:
Code:
[USER=\3]@\5[/USER]
Hi, does this code need to be updated at all? I get an error 500 after a few seconds when trying to use it. Other expressions I've used have worked fine, just this one is not working? Thanks.
 
Hi, does this code need to be updated at all? I get an error 500 after a few seconds when trying to use it. Other expressions I've used have worked fine, just this one is not working? Thanks.
I would venture a guess at no (to needing an update) given only a 500 error because 500 errors can be for a broad variety of reasons.

As I am going to guess that it is not an HTACCESS issue (you probably wouldn't have gotten to that page in the first place if there was) and that after years with no needed update that there is no syntax errors in the addon (and I know my regex there worked for someone at some point) it almost has to be a timeout issue.

I assume that you had a metric fox-ton of matches before you went to run the replacement?

If so, you can do them in batches by making a small edit to a php file in the addon to fix it. If you would like to try that edit for yourself check this post out and if it helps you please like that post to let Jake know that you appreciate his time.
 
Can someone help me with a specific example.

I need to find all instances of photobucket like this:

Code:
[IMG]http://[URL=http://s936.photobucket.com/user/vandyman71/media/IMG_0266_zps8d5526f6.jpg.html]
[IMG]http://i936.photobucket.com/albums/ad207/vandyman71/IMG_0266_zps8d5526f6.jpg[/IMG][/URL][/IMG]

and have it converted to this which completely deletes the first line above and delets the last 2 tags on the second line.

Code:
[IMG]http://i936.photobucket.com/albums/ad207/vandyman71/IMG_0266_zps8d5526f6.jpg[/IMG]
 
If so, you can do them in batches by making a small edit to a php file in the addon to fix it. If you would like to try that edit for yourself check this post out and if it helps you please like that post to let Jake know that you appreciate his time.
Perfect, it's working now, thank you for the help. :) Would be nice if that was in the overview, could save a few hours of head scratching, lol. ;)
 
Can someone help me with a specific example.

I need to find all instances of photobucket like this:

Code:
[IMG]http://[URL=http://s936.photobucket.com/user/vandyman71/media/IMG_0266_zps8d5526f6.jpg.html]
[IMG]http://i936.photobucket.com/albums/ad207/vandyman71/IMG_0266_zps8d5526f6.jpg[/IMG][/URL][/IMG]

and have it converted to this which completely deletes the first line above and delets the last 2 tags on the second line.

Code:
[IMG]http://i936.photobucket.com/albums/ad207/vandyman71/IMG_0266_zps8d5526f6.jpg[/IMG]
I assume that this was either a bad import, or an erroneous attempt at using this addon to change things? (Background info may help me to recognize the pattern better).

Knowing that and having a few more unique example of the same issue would help at determining the pattern in the error which you are trying to fix.

I happen to be motivated at this particular moment and may not be later but for your own sake and for whoever ends up helping you be it myself or someone else...when it is a long complex match or in your case what looks to be conversion/import/replacement errors you almost always want to post at least two unique examples as the first thing anyone does when using regex to replace many instances of a pattern is to solidly identify the pattern so as to catch everything and try to ensure that you don't catch something unwanted and start breaking your whole post table.
 
I jump in here.
Have many broken links in bbcode. Don't know where it comes from. In fact this doesn't matters really.
Just want to fix it.

So the pattern is:

"http://domain.xxx/showimage.php=

Where it should be

[url="http://domain.xxx/showimage.php=

I tried with phpmyadmin but the search did not return a result because I can't escape the ".
I searched the net found some different ways to deal with special characters but non of this worked.
So I'm a little desperate now.
 
Read the above post for some advice.

First thing you should try to do when looking for your issue because it potentially contains a problematic parsing of a link is to click edit on the post and then hit the "bbcode editor button"
dfsdfgd.webp


copy the text from there as it will show the actual text and then you will want to post that here in between [code] [/code] tags like this:

Code:
So it displays like this

Only then can one be sure they are not wasting their time trying to solve the wrong problem.


However, assuming that aside from xenforo parsing that link in the post here that what you posted is the actual and only thing you need changed (personally I really like to see the full text and a few characters padding that string so that I can see for myself otherwise how can I be sure I am not giving you something which has ill effect to your DB) this is an example using your example which shows how to do 'X not preceded by Y'


Quick find: domain
Regex: #(?<!=)"http://domain\.xxx/showimage\.php=#siu
Replace: [url=\0
 
Last edited:
I assume that this was either a bad import, or an erroneous attempt at using this addon to change things? (Background info may help me to recognize the pattern better).

Knowing that and having a few more unique example of the same issue would help at determining the pattern in the error which you are trying to fix.

I happen to be motivated at this particular moment and may not be later but for your own sake and for whoever ends up helping you be it myself or someone else...when it is a long complex match or in your case what looks to be conversion/import/replacement errors you almost always want to post at least two unique examples as the first thing anyone does when using regex to replace many instances of a pattern is to solidly identify the pattern so as to catch everything and try to ensure that you don't catch something unwanted and start breaking your whole post table.

Thanks for the reply.... I can assure you that I have not done any imports with this tool but it does seem that there are several factors that have caused issues over the years and by digging in recently and with the assistance of AndyB we have brought some massive problems to light. Some are from the import, some are from 17 years worth of links dying, some are from forum framework changes ie different forum software.

I am really wanting to use this tool to identify and list out same type issues meaning that because I have some many different types of image problems I need to address each one with a different process. What I have found is that there are some general similarities that would allow me to manually fix each one very quickly if I can identify them using this tool. I will probably not click the easy button but would really love to be able to pull all of my photobucket problems up at one time because the fix seems to be consistently the same.

The life and time of a system admin right!

Thank you again for the response, the knowledge and experience you guys have is invaluable here...
 
Top Bottom