Given a string, how can I identify the string has a colon in between a colon and a semi-colon?
For example, I want to identify that the following has a :
in between :
and ;
. If t开发者_开发百科his is the case, I want to replace the colon in the middle.
background-image: url('http://google.com/img.jpg');"
I can't come up with a regex for the life of me. I can only match the whole url('http://google.com/img.jpg')
. What regex can I use that can do this for me?
$pattern = '';
$matched = preg_replace($pattern, '|__|', $string);
$pattern = '/(:.*?):(.*?;)/s';
$matched = preg_replace($pattern, '$1|__|$2', $string);
精彩评论