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);
精彩评论