• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Find / Replace Help

akia

Well-known member
#1
Can someone help me with the find and replace regexs for correcting my site conversion:

I need to correct posts like this:

Code:
<blockquote class="ipsBlockquote" data-author="Matty" data-cid="3770" data-time="1359401115"> Welcome Jai, I'm sure I know you from somewhere! :p </blockquote>
So that they show as proper quote tags, it doesn't matter though if they have the person being quoted or link to the original post though if that makes it simpler.

Code:
<img src="http://i57.photobucket.com/albums/g226/star_twister/Egg_zps7fc1c4bd.png" alt="Egg_zps7fc1c4bd.png">
So that they show as attached image links

and

Code:
<a href="http://factualfacts.com/science-facts/ecstasy-could-be-a-cure-for-cancer/">http://factualfacts.com/science-facts/ecstasy-could-be-a-cure-for-cancer/</a>
to turn urls back into links
 

akia

Well-known member
#2
and another one I need help with:

Code:
<a href="http://www.youtube.com/watch?v=3jNlIGDRkvQ">http://www.youtube.com/watch?v=3jNlIGDRkvQ</a>
So that it shows up as a proper Youtube video.
 

akia

Well-known member
#3
Is there also a way to clean up these types as well:

Code:
<span style="font-size:14px;"></span>
<div style="font-size:46.1067px;font-family:sans-serif;">
<div style="font-size:46.1067px;font-family:sans-serif;">
<span style="font-family:arial, helvetica, sans-serif;">
I've got rid of the closing tags as they are all the same, its jsut the start bits I don't know how to remove
 

Jake Bunce

XenForo moderator
Staff member
#4

Jake Bunce

XenForo moderator
Staff member
#6
I need to correct posts like this:

Code:
<blockquote class="ipsBlockquote" data-author="Matty" data-cid="3770" data-time="1359401115"> Welcome Jai, I'm sure I know you from somewhere! :p </blockquote>
So that they show as proper quote tags, it doesn't matter though if they have the person being quoted or link to the original post though if that makes it simpler.
Quick Find: <blockquote

Regular Expression: #<blockquote class="ipsBlockquote" data-author="([^"]+)".+>([^<]+)</blockquote>#siU

Replacement String: [quote=\1]\2[/quote]
 

Jake Bunce

XenForo moderator
Staff member
#8
and

Code:
<a href="http://factualfacts.com/science-facts/ecstasy-could-be-a-cure-for-cancer/">http://factualfacts.com/science-facts/ecstasy-could-be-a-cure-for-cancer/</a>
to turn urls back into links
Quick Find: <a href

Regular Expression: #<a href="([^"]+)">([^<]+)</a>#siU

Replacement String: [url=\1]\2[/url]
 

Jake Bunce

XenForo moderator
Staff member
#9
Is there also a way to clean up these types as well:

Code:
<span style="font-size:14px;"></span>
<div style="font-size:46.1067px;font-family:sans-serif;">
<div style="font-size:46.1067px;font-family:sans-serif;">
<span style="font-family:arial, helvetica, sans-serif;">
I've got rid of the closing tags as they are all the same, its jsut the start bits I don't know how to remove
To remove *only the opening tags*:

Quick Find: <div

Regular Expression: #<div.*>#siU

Replacement String:



Quick Find: <span

Regular Expression: #<span.*>#siU

Replacement String:
 

akia

Well-known member
#11
For people that are trying to import from IPB and need to clean up the post contents, with everything Jakes posted above and the mysql code below, is everything anyone needs to complete the import and clean everthing up for reference for anyone that needs it.

Code:
UPDATE xf_post SET message = REPLACE(message, 'Â', ' ');
UPDATE xf_post SET message = REPLACE(message, '<p>', '');
UPDATE xf_post SET message = REPLACE(message, '</p>', '');
UPDATE xf_post SET message = REPLACE(message, '<strong>', '');
UPDATE xf_post SET message = REPLACE(message, '</strong>', '');
UPDATE xf_post SET message = REPLACE(message, '<em>', '');
UPDATE xf_post SET message = REPLACE(message, '</em>', '');
UPDATE xf_post SET message = REPLACE(message, '<sub>', '');
UPDATE xf_post SET message = REPLACE(message, '</sub>', '');
UPDATE xf_post SET message = REPLACE(message, '<li>', '');
UPDATE xf_post SET message = REPLACE(message, '</li>', '');
UPDATE xf_post SET message = REPLACE(message, '<ul>', '');
UPDATE xf_post SET message = REPLACE(message, '</ul>', '');
UPDATE xf_post SET message = REPLACE(message, '<div>', '');
UPDATE xf_post SET message = REPLACE(message, '</div>', '');
UPDATE xf_post SET message = REPLACE(message, '</span>', '');
If I spot any others I'll add them to the list above.
 

AWS

Well-known member
#12
Thanks to you and Jake for this. I remember doing all this, but, didn't document it when I converted. I'm in the process of doing another site and this is going to make things easier.
 
#13
Hey,

i hope you don't mind if i use this thread for another find / replace question.

I would like to get rid of those broken links and images.

Code:
[IMG]http://MYDOMAIN/forum/picture.php?albumid=XXX&pictureid=YYY[/IMG]
[url='http://MYDOMAIN/forum/picture.php?albumid=XXX&pictureid=YYY'][img]http://MYDOMAIN/forum/picture.php?albumid=XXX&pictureid=YYY&thumb=1[/img][/url]
They should all be replaced with the text "image removed". Would be great if you could help me with this. ;) Thanks a lot!
 

Jake Bunce

XenForo moderator
Staff member
#14
Hey,

i hope you don't mind if i use this thread for another find / replace question.

I would like to get rid of those broken links and images.

Code:
[IMG]http://MYDOMAIN/forum/picture.php?albumid=XXX&pictureid=YYY[/IMG]
[url='http://MYDOMAIN/forum/picture.php?albumid=XXX&pictureid=YYY'][img]http://MYDOMAIN/forum/picture.php?albumid=XXX&pictureid=YYY&thumb=1[/img][/url]
They should all be replaced with the text "image removed". Would be great if you could help me with this. ;) Thanks a lot!
Quick Find: [url='http://www.mydomain.com/forum/picture.php[/plain]

[b]Regular Expression:[/b] [plain]#\[url='http://www\.mydomain\.com/forum/picture\.php\?albumid=[^']+'\]\[img\]http://www\.mydomain\.com/forum/picture\.php\?albumid=[^\[]+\[/img\]\[/url\]#siU

Replacement String: image removed



Quick Find: [img]http://www.mydomain.com/forum/picture.php

Regular Expression: #\[img\]http://www\.mydomain\.com/forum/picture\.php\?albumid=[^\[]+\[/img\]#siU

Replacement String: image removed
 
#15
Hey,

i need to fix smth like this:

<!--QuoteBegin-Hollii+Dec 21 2005, 21:38-->ZITAT(Hollii @ Dec 21 2005, 21:38)</div><!--QuoteEBegin-->
<!--QuoteEnd--></div><!--QuoteEEnd-->
<p style="color:rgb(40,40,40);font-family:helvetica, arial, sans-serif;">
<!--fonto:Calibri--><!--/fonto--><!--sizeo:3--><!--/sizeo-->
<!--fonto:Calibri--><!--/fonto--><!--sizeo:3--><!--/sizeo--><!--sizec--><!--/sizec--><!--fontc--><!--/fontc-->
<!--sizec--><!--/sizec--><!--fontc--><!--/fontc-->


Is there an ability ä, ö, ü in posts to replace automatically ?

Thanks alot =)
 

EQnoble

Well-known member
#20
i need help..!

[img width=550 height=429]*[/img]

how to this change ?
When asking for help with a replacement you need to include a full example...meaning do not edit it at all from how it appears in your editor at your site (unless it contains a link to an adult content type site).

The example code you post you should be getting in this way...

  • Click edit on a post containing stuff you want to be replaced
  • click on this image ccxcxcxz.png to show the bbcode editor
  • copy the content of the bbcode and include it's surrounding tags and that is what you paste in a code block here


Here is an example of what to post when asking for replacement help...
____EXAMPLE________________________________________________
I need help replacing
from this:
Code:
[img width=550 height=429]http://xenforo.com/community/data/avatars/m/1/1321.jpg?1382353461[/img]
to this:
Code:
[IMG]http://xenforo.com/community/data/avatars/m/1/1321.jpg?1382353461[/IMG]
___________________________________________________________



To which I would be able to respond with something like:


Quick Find:
Code:
[img

Regular expression:
Code:
#(\[img)\swidth=[0-9]+\sheight=[0-9]+(])#siu
Replacement String:
Code:
\1\2


Doing things this way just makes it easier for everyone and for future reference there is a bunch of questions already asked and answered here so it might not be a bad idea to post your requests there