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

Post replace

Discussion in 'XenForo Questions and Support' started by MrC, Mar 5, 2013.

  1. MrC

    MrC Active Member

    I am using Post Replace addon by Kier to replace a string, say "xyz", with a space. Should I put " " (space - without the quotation marks) in the Replacement String box? If not, do I need to put some special character, which represents the space character, in the box? And what should the special character be?

    Thanks.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    For simple replacements you can use a direct query on the database:

    Code:
    UPDATE xf_post
    SET message = REPLACE(message, 'xyz', ' ');
    
    You don't need Kier's addon for this simple replacement.
     
  3. MrC

    MrC Active Member

    Sorry :). My example was over simplified. To be precise, I am trying to remove the tag lines created by the Double Post addon and replace each tag line by a space. The tag lines have the following format:

    Code:
    [DOUBLEPOST=1352988138][/DOUBLEPOST] (where the number is the posted date)
    So I used:

    Code:
    Quick Find: [DOUBLEPOST
     
    Regular Expression: #\[DOUBLEPOST=\d+\]\[/DOUBLEPOST\]#siU
     
    Replacement String: " " (without the quotation marks)
    I tested the above, it seemed to find all the tag lines created by Double Post, but the Replacement String boxes were empty (no space characters). So I am guessing I did not do it correctly.
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    It's correct. I tested it.

    A space character replacement will show as "empty". It only shows the replacement for the actual matched text, not the entire post.
     
    MrC likes this.
  5. MrC

    MrC Active Member

    I created a simple text for testing: "helloxyzkJake Bunce". And I did the following with Post Replace

    Code:
    Quick Find: xyzk
     
    Regular Expression: #xyzk#
    Replacement String: " " (without the quotation marks)
    The text, after the replacement, became "helloJake Bunce". But it should be "hello Jake Bunce".
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Oh.

    You could replace it with some non-empty string and then run a replacement query on that string.
     
    MrC likes this.
  7. MrC

    MrC Active Member

    Yeah, that trick worked. I replaced "xyzk" with "xyzk xyzk" and then removed "xyzk". The space in "xyzk xyzk" stayed!
     
    Jake Bunce likes this.

Share This Page