-4

I feel like I can learn a lot by seeing these two regular expressions as one. Mainly selecting the space in between > and < while not selecting the > and < themselves, so I can replace it with "" rather than "><". Is there a way that these could be merged without selecting that space?

    $html = preg_replace('/(\n)|(\r)/',"",$html);
    $html = preg_replace('/>(\s+)</',"><",$html);

1 Answer 1

2
$html = preg_replace('/[\n\r]+|(?<=>)\s+(?=<)/',"",$html);

Not the answer you're looking for? Browse other questions tagged or ask your own question.