Replace in the database for the mask?

Do in mysql query like this:

UPDATE table SET text = replace(text,'subject','<a href="/predmet">object</a>');


there is a replacement: subject to < a href = " predmet ">subject a>

please tell me how to make this query to replace were those in which:

subject < a href = "/predmet">subject a>
subject < a href = "/predmet">subject a>
the subject - < a href = "/predmet">subject a>
June 7th 19 at 14:23
1 answer
June 7th 19 at 14:25
Solution
Use in the sql query either with Like or RegExp.
If you will handle on the side php, use preg_replace
and in preg_replace as a mask will look the word object? to replace was predmet and predmetom and predmeta? - Laurianne_White50 commented on June 7th 19 at 14:28
for example this
/(object)\W{0,2}[^<\/a>]/g
Where \W {0,2} any character occurring 0 to 2 times - Verona.Torp34 commented on June 7th 19 at 14:31
if the answer helped, please mark the solution if did not help or have questions - please ask - Verona.Torp34 commented on June 7th 19 at 14:34
using str_ireplace and tell me you can make such a change

try here

$source = str_ireplace("bbb", "kkk", $myrow['full_text']);

how can I get mask to write to

the subject is replaced by <link>object<link>
or
the subject changed to <link>object<link> - Laurianne_White50 commented on June 7th 19 at 14:37
not be here. As we said php.net c of. documentation
str_ireplace — case-insensitive version of the function str_replace()

And str_replace() we only works with static strings, not to masks.
To replace the mask you need to use preg_replace - Verona.Torp34 commented on June 7th 19 at 14:40

Find more questions by tags PHPMySQLSQL