How can I convert all multiple white space inside any given HTML element to a single space using regex and preg_replace in php?
Eg: <div class="myClass" jsaction="UjQMac:.CLIENT" data-id="3739" >Edit</div>
Cleaned: <div class="myClass" jsaction="UjQMac" data-id="3739">Edit</div>
All multiple spaces removed and only single spaces retained. Also, the >
is replaced with a >
I've been trying unsuccessfully with this regex \<(\s+)\>
. Can you help?
Edit:
The regex (?:(\s{2,})|(\s>))
from the answer below works fine, but does not match only between <
& >