Monday 15 April 2013

php - Trim all whitespace from within html tags with preg_replace -



php - Trim all whitespace from within html tags with preg_replace -

it seems have special problem couldn't find related solution on web far. have smarty templates , can pretty much remove unnecessary whitespace trimwhitespace filter after making slight modifications. cannot rid of leading whitespace within tags. please have @ next 2 examples:

<h1>a headline without leading whitespace</h1> <h1> headline formatted ide </h1>

my problem smarty trimwhitespace output filter not trim sec example. when place icon before headline using css :before, there whitespace between icon , sec illustration not when applied first example.

is possible utilize preg_replace trim sec illustration looks same in html first illustration does?

(?<=<h1>)\s*|\s*(?=<\/h1>)

try this.see demo.

http://regex101.com/r/hq1rp0/61

php regex preg-replace smarty

No comments:

Post a Comment