Resource icon

Post Content Find / Replace 1.0.0

No permission to download
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...
 
Ah ok that clarifies things and damn... 17 years, congrats.

Yeah manually changing all these things after 17 years worth of accumulation is going to be a nightmare and I feel your pain.

Is photobucket the only one you are having problems with or do you have a slew of dead end linkery and format madness with various sites and bbcodes?

The tool is actually a lot more powerful than just find and manually replace. Oddly if you have to do a process that seems too complex to do there is a pretty good chance that it could be done with this tool if you can wrap your head around regex (or have someone to do it for you). Your photobucket example is one such process.

Tell you what, you use an example image of a busa and I have to assume it is yours so in light of my sympathy for you (j/k the busa is nice and a lot of bike but I used to ride an rC51) this one is on me ;)


Quick Find:
Code:
photobucket

Regular expression:
Code:
#\[(img)](http://)\[URL=\2[^\.]+.(photobucket\.com)/user/([^/s\.]+)/media/([^\]]+)\.html][\s]+((\[\1]\2[^\.]+.\3)/albums/[^\s\/]+/\4/\5(\[/\1]))\[/url]\8#siu

Replacement String:
Code:
\6

It's more complex than it might need to be but it will ensure that it only matches the erroneous image page link if the image in it is the same one in the album in the actual img tag after it.
 
Finally i got it.

From old vb to xf:

Code:
[SURL="/forum/showthread.php?t=27418&highlight=something"]Watch it[/SURL]


Code:
[SURL=

#\[SURL=".+t=(\d+).+](.+)\[/SURL]#siu

[URL="/new-forum/thread/\1"]\2[/URL]



Thank you for programing it!
:)
 
Last edited:
BTW: it would be really perfect to reduce the queries to a number.
Maybe you want to add a field to the addon and we start with a smaller number instead of replacing everything? (I have really a lot of post to replace things like .+ )
 
Hmmm, i dont know how to get all hits.

For

Code:
[size=2]lala[/size] [size=2]huhu[/size]

I get only

Code:
lala[/size] [size=2]huhu

back. What can i do, please?
 
Back
Top Bottom