Im having propbles doing this regex to get everything after a certain character (* in this case) and ends with a newline in PHP.
I have:
texttextext
*Sometext
*othertext
texttextex
i want to be able to get "*Sometext and "*othertext" and add <b></b>
to them.
Already tried with
$a = array(
"/\*(.*?)\n/is"
);
$b = array(
开发者_Go百科 "<b>$1</b>"
);
$texto = preg_replace($a, $b, $texto);
but it does not work. What im doing wrong?
"/^\*(.*?)\n/im"
You just have to add ^
to match the beginning of the line. This requires the /m
multiline flag.
The /s
flag however was wrong there, as that allowed .*
to also match linebreaks - which you do not want.
精彩评论