Skip to content

Instantly share code, notes, and snippets.

@mapkyca
Created April 19, 2012 12:52
Show Gist options
  • Save mapkyca/2420796 to your computer and use it in GitHub Desktop.
Save mapkyca/2420796 to your computer and use it in GitHub Desktop.
Quickly remove non-alpha chars from a string
// Quick regexp to remove non-alpha chars from a string. Very handy
$string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string);
@mapkyca
Copy link
Author

mapkyca commented Mar 11, 2018

Drop the \s if you don't want to have whitespace as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment