Reputation: 145
I am trying to update a column in MariaDB using regexp_replace. I've tested this out in this fiddle and it works just fine, however when I update and export the table, it seems that the match is replaced by the literal regex pattern - href="#h_$1" .
This is my query:
UPDATE blog_posts
SET blog_content = regexp_replace(blog_content, 'href="[^#"]+#h_(.+)"', 'href="#h_$1"');
Did anyone encounter this before and if yes how can I solve it?
Upvotes: 0
Views: 304
Reputation: 15057
You can use \\1 to select the pattern. try:
UPDATE blog_posts
SET blog_content = regexp_replace(blog_content, 'href="[^#"]+#h_(.+)"', 'href="#h_\\1"');
see manual: https://mariadb.com/kb/en/regexp_replace/
Upvotes: 1