开发者

How to use regex to append string to the matched results

I'm trying to replac开发者_如何学Pythone 0-1. with 0-1.<br> how do i do that?

update:

Sorry for my vague question. You guys misunderstood me. '0-1.' is the pattern i want to replace, which means the pattern should be like `"/(\d)+(-)*(\d)*\./"` and the string may be '1.' '0-1.' or something that expression could represent


You can use a standard PHP function:

str_replace('0-1.', '0-1.<br>', $yourString);


How about:

preg_replace("/(\d+(?:-\d+)?\.)/", "$1<br>", $string);


You can use preg_replace like this:

preg_replace("/(0-1\.)/", "$1<br>", $string);

or, as you know the substitution already:

preg_replace("/0-1\./", "0-1.<br>", $string);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜