Can anyone tell me why this regex is causing a php segmentation fault?
$text = preg_replace('~[\s\r\n]+(?=(?:(?!<tr).)*<\/tr>)~is', ' ', $text);
I need to remove line breaks (\n\r
) in tr
elements. Maybe there is a better regex to do that or maybe there is a non-regex solution?
UPDATE:
I need to remove line breaks only inside tr
element. Other line breaks should be untouched.
UPDATE2:
I am not parsing HTML with regex. I am getting email body (it can be huge html without tables, it can be plain text already), removing line breaks in tr's, stripping HTML tags and using plain text.
UPDATE3:
Please do not answer "use parser" or downvote. I don't think it suits this case very well and if I am wrong please explain why am I wrong. I will really apreciate it. Thank you.