0

im looking for a way, to replace a word inside a certain text area. I already found the code:

UPDATE table_name SET field = REPLACE(field, 'word1', 'word2')

But now i want to replace only the words that are inside brackets [a][/a] and not inside the brackets [b][/b]

The text in the table is structed in a way that they are different textparts, that are divided in categories [a][/a],[b][/b],[c][/c]... and now i only want to replace the words inside one of these areas and not inside the others.

Is that possible?

Jens
  • 67,715
  • 15
  • 98
  • 113
Pascal
  • 1
  • 1
    Have you tried ´UPDATE table_name SET field = REPLACE(field, '[a]word1[/a]', [a]'word2[/a]')`? – Jens Mar 09 '16 at 10:44
  • ^ If there are multiple words in the tags, that won't work. – Matt Mar 09 '16 at 10:46
  • Might be worth looking at http://dev.mysql.com/doc/refman/5.7/en/regexp.html – Matt Mar 09 '16 at 10:47
  • yes there are whole paragrahps in the tags. On here: [link](http://stackoverflow.com/questions/10465288/mysql-update-with-regexp) they say that mysql doesnt support regexp-based replace. The workarounds seem incredible complicated. Does no one know an easy solution? – Pascal Mar 09 '16 at 17:32

0 Answers0