Regex Trim Whitespace


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function trim_whitespace($source)
  2. {
  3. $pattern = '/[^\w]\s*/';
  4. return preg_replace($pattern, ' ', $source);
  5. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.