Resource icon

Post Content Find / Replace 1.0.0

No permission to download
#\[attach]#siu

that should work fine for you though if you wanted to you could change this one with a sql query...either way unless you have tens of thousands of occurrences to change it really doesn't matter.
Thanks, I'll give that a try.

Also, I found some replacement advice you gave earlier and wanted to ask about it. I have AME tags I need to address. Here's an example of one I found:
Code:
[ame="http://www.youtube.com/watch?v=Hkcwl8T_Th8&list=UUd8JfwGxmRb5P7nMVRzSPng&index=1&feature=plcp"]Closing the FIAV - The Free Way[/ame]
I used:

Quick Find: [ame=
Regular Expression: [code]#\[ame="http://(?:www.)?(youtube)[^=]+=([^"]+)"][a-z0-9\s-\[\]()]+\[/ame]#siu[/code]
Replacement String:
Code:
[media=\1]\2[/media]

It's going to covert to:
Code:
[media=youtube]Hkcwl8T_Th8&list=UUd8JfwGxmRb5P7nMVRzSPng&index=1&feature=plcp[/media]

Is that the way it's supposed to look? It just didn't look right.
 
Is that the way it's supposed to look? It just didn't look right.
No it's not. (pls if you can just link to the post id rather than reposting it, the context helps as I usually see this thread when my brain is a million miles away)


Also as you notice, just running expressions that others randomly post is a Russian Roulette sort of thing, only because if a person running an expression knew enough to catch a bug in an expression and offer a fix they probably wouldn't need the help in the first place and with that logic there is no real way to be certain that what you see in a code box actually applies to what you seek and while you can normally play with things to see how they work, regex has a permanence to it that when used wrong can give you a really bad day and since I don't have anything to work off of but the examples people give me I am basically creating these off the top of my head assuming some sort of pattern out of only a certain few examples.




Again I don't know that this will catch everything but you will match a ton with this.

Quick Find:
Code:
youtube

Regular expression:
Code:
#(?:\[ame="[^\.]+\.youtube\.com/watch\?v=)([a-z0-9_-]{11})(?:(?:.*?(?!"]?)).)?(?:"])(?:.*?(?!\[/ame]?).)(?:\[/ame])#siu

Replacement String:
Code:
[media=youtube]\1[/media]
 
Last edited:
Thanks for the reply. I ran another test using this new replacement code and it caught a bunch. One issue I noticed though is that posts that have multiple embedded videos, the code is replacing them all with one new embedded video, or at least that's what it looks like it's trying to do in the test. Here's a sample post with multiple videos:
http://www.dsmtuners.com/threads/top-50-world-quickest-4g63.454245/#post-153167718



That seems pretty much impossible....

llort.webp

It works, I have tested it now so if beyond that it doesn't work for you I have to assume you are entering something in incorrectly.

If you have more examples that can point out an issue please post them here...I can't afford to spend time searching other's forums when I am helping for free and should be out trying to find tomorrows dinner.
 
Last edited:
Thanks for the reply. I ran another test using this new replacement code and it caught a bunch. One issue I noticed though is that posts that have multiple embedded videos, the code is replacing them all with one new embedded video, or at least that's what it looks like it's trying to do in the test. Here's a sample post with multiple videos:
http://www.dsmtuners.com/threads/top-50-world-quickest-4g63.454245/#post-153167718
I took a minute when i wasn't deprived of sleep and edited the expression in this post so you can try and rerunning it...I realized an error on my part that should have been obvious had I not basically been sleeping and another oversight in logic based on possible parameters and such. Let me know if that works out for you.
 
I took a minute when i wasn't deprived of sleep and edited the expression in this post so you can try and rerunning it...I realized an error on my part that should have been obvious had I not basically been sleeping and another oversight in logic based on possible parameters and such. Let me know if that works out for you.
I'll try that out, thanks.
 
I need a little help with a replacement, if someone would be so kind...

On my old VB3 site, I was using a custom add-on for displaying videos. After import to XF, the url for a youtube video looks like this:

[URL='http://www.youtube.com/watch?v=t4wziXpaQ5I']Elecraft KX3 on 4m / 70MHz - YouTube[/URL]

Can someone help me out with a replacement search /replacement to get it to a the standard [media=youtube tag?

Thanks!

Note: edited to get rid of auto link embed
 
Last edited:
Take a backup first.

Code:
UPDATE xf_post SET message = REPLACE(message,'[MEDIAyoutube]','[MEDIA=youtube]');

What is the closing tag?
It should be /MEDIA.
 
If you prefer to use the addon it would like this, although I'm not sure if that was just an example YouTube video? Because that YouTube URL is not valid and as far as I know valid YouTube video IDs have to be 11 characters and can't contain question marks.

Quick Find:
Code:
MEDIAyoutube

Regular Expression:
Code:
#\[MEDIAyoutube\]([\w\-\?]{10})\[\/MEDIA\]#

Replacement String:
Code:
[MEDIA=youtube]\1[/MEDIA]
 
Anyone have the code for
Code:
[img width=449 height=480]
and need it to be
Code:
[IMG]
I did an SMF > phpBB > Xenforo move

Would this be correct??????

Quick Find:
Code:
[img
Regular Expression:
Code:
#\[img width=[^>]+>(<param[^>]+></param>)
Replacement String:
Code:
[img]
 
Back
Top Bottom