Posted By

resting on 07/25/11


Tagged

regex


Versions (?)

Regex Trim Whitespace


 / Published in: PHP
 

  1. function trim_whitespace($source)
  2. {
  3. $pattern = '/[^\w]\s*/';
  4. return preg_replace($pattern, ' ', $source);
  5. }

Report this snippet  

You need to login to post a comment.