与PHP不同,我不相信mySQL有任何preg_replace()
功能,只能通过REGEXP进行匹配。以下是代码中的字符串:
http://ourcompany.com/theapplestore/...
http://ourcompany.com/anotherstore/...
http://ourcompany.com/yetanotherstore/...
如您所见,http://ourcompany.com/
中有一个常量,但还有一个变量字符串,即theapplestore
,anotherstore
等等。
我想替换常量字符串,加上变量字符串,然后在变量字符串后面加上斜杠(/),加上单个短代码值,即{ {1}}
修改
如果它有帮助,商店代码总是相同的长度,它们将是
{{store url=''}}
sch131785
sch185399
等等
即,它们都是9个字符长
我该怎么做?感谢。
答案 0 :(得分:0)
我认为这可能有用:目前没有办法在mysql中执行此操作。使用REGEXP查找,是的;替换,没有。也就是说,还有一篇文章提到了扩展库,sagi
:
答案 1 :(得分:0)
MariaDB-10.0.5具有REGEXP_REPLACE(),REGEXP_INSTR()和REGEXP_SUBSTR()
答案 2 :(得分:-1)