Post replace

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.
 

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.
 

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.
 

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.
 
Reactions: MrC

MrC

Active 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.
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".
 

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.
 
Reactions: MrC

MrC

Active member
Yeah, that trick worked. I replaced "xyzk" with "xyzk xyzk" and then removed "xyzk". The space in "xyzk xyzk" stayed!
 
Top