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

Find / Replace Help

Discussion in 'Installation, Upgrade, and Import Support' started by akia, Mar 3, 2013.

  1. akia

    akia Well-Known Member

    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
     
  2. akia

    akia Well-Known Member

    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.
     
  3. akia

    akia Well-Known Member

    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
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Use Kier's addon:

    http://xenforo.com/community/threads/post-content-find-replace.6548/

    Quick Find: <a href

    Regular Expression: #<a href="http://www\.youtube\.com/watch\?v=([^"]+)">.+</a>#siU

    Replacement String: [media=youtube]\1[/media]
     
    gmaister22 and akia like this.
  5. akia

    akia Well-Known Member

  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Quick Find: <blockquote

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

    Replacement String: [quote=\1]\2[/quote]
     
    gmaister22 and akia like this.
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Quick Find: <img

    Regular Expression: #<img src="([^"]+)".+>#siU

    Replacement String: [img]\1[/img]
     
    gmaister22 and akia like this.
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Quick Find: <a href

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

    Replacement String: [url=\1]\2[/url]
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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 likes this.
  10. akia

    akia Well-Known Member

    Perfect!! You are amazing Jake!!!!! :D
     
  11. akia

    akia Well-Known Member

    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.
     
    Eagle, Adam Howard and Jake Bunce like this.
  12. AWS

    AWS Well-Known Member

    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. Crazy-Achmet

    Crazy-Achmet Active Member

    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!
     
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Quick Find: [url='http://www.mydomain.com/forum/picture.php

    Regular Expression: #\[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
     
    Crazy-Achmet likes this.
  15. Pascal Sprei

    Pascal Sprei Member

    Hey,

    i need to fix smth like this:



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

    Thanks alot =)
     
  16. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Some of those tags look incomplete. Can you provide a link to a post showing those problems? That way I can see the whole post and be certain about the replacement.
     
    Adam Howard likes this.
  17. Pascal Sprei

    Pascal Sprei Member

    Can i send you a PN with a link of the forum ?
    Then you can have a look how stupid it like after import.

    Many thanks ;)
     
  18. CGSTUDYO

    CGSTUDYO New Member

    i need help..!

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

    how to this change ?
     
  19. Jeremy

    Jeremy XenForo Moderator Staff Member

    From? To? We can't help without more information.
     
    CGSTUDYO and Adam Howard like this.
  20. EQnoble

    EQnoble Well-Known Member

    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
     

Share This Page