Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 1732

[3.3.x] Support Forum • Re: [split] replacing text in forum

$
0
0
You can use REGXP_REPLACE for this.

https://mariadb.com/kb/en/regexp_replace/

First test it. this will give you two columns side by side to preview changes. :

Code:

SELECT post_text, REGEXP_REPLACE(post_text,' I love my (cat|dog) ',' I love my horse ') AS new_match FROM phpbb_posts  WHERE post_text REGEXP ' I love my (cat|dog) ';
To run it:

Code:

UPDATE phpbb_posts SET post_text_column = REGEXP_REPLACE (post_text, ' I love my (cat|dog) ',' I love my horse ');
The match is also placeholder:

Code:

UPDATE phpbb_posts SET post_text_column = REGEXP_REPLACE (post_text, ' I love my (cat|dog) ', # \\1 will either be cat or dog. ' I hate my \\1. ' );
That' very simplistic example and regex can be mind numbing trying to read. Matching some.random.name@example.com is even more difficult because it's enclosed in formatting for the bbcode. I've found chatGTP quite helpful for creating regex but you need to be precise in what you are asking.

Statistics: Posted by thecoalman — Fri Sep 27, 2024 6:14 pm



Viewing all articles
Browse latest Browse all 1732

Trending Articles