Sergio Flores
Sergio Flores

Reputation: 5427

Remove white space from entire Html but inside pre with regular expressions in php

I'm using the following regular expression found in this post: (?<=\s)\s+(?![^<>]*)

When I do this:

echo gzencode( trim( preg_replace('/(?<=\s)\s+(?![^<>]*<\/pre>)/', '', $html) ), 9);

The spaces are replaced in all html. even inside pre tags. I need this to compress the entire page.

Upvotes: 0

Views: 723

Answers (1)

Arthur Ronconi
Arthur Ronconi

Reputation: 2428

Try this:

echo gzencode( trim( preg_replace('/\s+(?![^<>]*<\/pre>)/', '', $html) ), 9);

=)

Upvotes: 1

Related Questions