I am using this regular expression to remove white space and line breaks from a HTML document.
However, it doesn’t seem to handling line breaks very well.
preg_replace('/(?:(?<=\>)|(?<=\/\>))(\s+)(?=\<\/?)/', '', $HTML);
How can I improve the above?
I am only trying to remove spaces between beginning and end of HTML tags.
How about this regex? It’s not perfect (it only handles whitespace at the beginning and end of the line) but it works for me.