Skip to content

Instantly share code, notes, and snippets.

@mapkyca
Created April 19, 2012 12:52
Show Gist options
  • Select an option

  • Save mapkyca/2420796 to your computer and use it in GitHub Desktop.

Select an option

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

mapkyca commented Mar 11, 2018

Copy link
Copy Markdown
Author

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