preg_replace and multiple lines?
Posted: Thu Apr 17, 2003 8:34 am
I want to replace text with preg_replace that necessarily includes line-breaks.
How can I have preg_replace support multiple lines, i.e. line-break ("\r\n"). For some reason the parameters "\m" (as suggested on php.net) and "\s" don't work, and including an optional \r\n doesn't do it either - it all works fine with preg_match_all but not with preg_replace
Surely there must be a more elegant solution than to make it a one-line string by doing a preg_split on the string at the line-breaks and imploding it with a linebreak-marker then replace things and put the linebreaks back in?
Hmmm...help?
How can I have preg_replace support multiple lines, i.e. line-break ("\r\n"). For some reason the parameters "\m" (as suggested on php.net) and "\s" don't work, and including an optional \r\n doesn't do it either - it all works fine with preg_match_all but not with preg_replace
Surely there must be a more elegant solution than to make it a one-line string by doing a preg_split on the string at the line-breaks and imploding it with a linebreak-marker then replace things and put the linebreaks back in?
Hmmm...help?