开发者

Regex replace the colon in between a colon and a semi-colon

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜