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(
"<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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.