If I use a mysql statement to replace it, how can I write it? My questions:
Returns the regular expression used to intercept a website.
Http://p.yiqifa.com/n? K = small & spm = 1.1.1.1 & t = http://www.xuansou.com/
If you want to replace all the previous content in the second http: // URL with Null
That is, just want to keep http://www.xuansou.com/
How can this problem be solved? thank you. I'm a Cainiao.
The correct answer from the jordan102 moderator has been completed:
$ S = 'http: // p.yiqifa.com/n? K = Latest & spm = 1.1.1.1 & t = http://www.xuansou.com /';
Echo preg_replace ('/. +? T =/', '', $ s );
The above code is used for php code,
If I use a mysql statement to replace it, how can I write it?
Reply to discussion (solution)
Just extract it.
SUBSTRING_INDEX (field name,'t =',-1)
Update alibaba_site set url = replace (url, SUBSTRING_INDEX (url,'t = ',-1), '') where id = 2452
In this case, all the values of the entire field are used up.
Update alibaba_site set url = replace (url, SUBSTRING_INDEX (url,'t = ',-1), '') where id = 2452
In this case, all the values of the entire field are used up.
Update alibaba_site set url = replace (url, SUBSTRING_INDEX (url,'t = ',-1), '') where id = 2452
In this case, all the values of the entire field are used up.
Update ylmf_site set url = SUBSTRING_INDEX (url, 'url = ',-1) where id = 2452
This is acceptable, but there is a problem.
That is, the strings before the last URL are changeable.
Each replacement batch must be modified once.
What are the 'previous string?
It is best to use php for processing. mysql does not support complex regular expressions. if you feel that the values stored in fields are not satisfied with your own requirements, you can write a regular expression replacement script in php for execution.
What are the 'previous string?
URL 1: http://click.linktech.cn /? M = idaphne & a = A100113464 & l = 99999 & l_cd1 = 0 & l_cd2 = 1 & u_id = 88819 & tu = http % 3A % 2F % 2Fwww.xuansou.com % 2F
URL 2: http://p.yiqifa.com/n? K = small & spm = 1.1.1.1 & t = http://www.xuansou.com/
The front of the http://www.xuansou.com in these two URLs is "'front strings '"
I am afraid that mysql regular expressions are not easy to implement. if not, you can also use your xxxx_index, although it is a little troublesome.
Update ylmf_site set url = concat ('http', SUBSTRING_INDEX (url, '= http',-1) where id = 2452