Skip to content

Main Navigation

Nick Stallman
  • Contact

Tag: regex

Strip all but certain characters from a string in PHP (such as alphanumeric, numeric, etc…)

Posted on May 9, 2012 (August 31, 2026) by Nick

The #1 result in Google for stripping characters out of strings in PHP is awful and uses the deprecated ereg_replace function so lets make a new search result using preg_replace which is much better, faster and it is fully supported in PHP 5 and 7. Allow only alpha-numeric: Only numeric: Alpha-numeric with whitespace: The ^ […]

Read More… from Strip all but certain characters from a string in PHP (such as alphanumeric, numeric, etc…)

Tagged PHP, regex24 Comments on Strip all but certain characters from a string in PHP (such as alphanumeric, numeric, etc…)

Recent Posts

  • Reverse engineering the ZJ Beny EV charger firmware
  • CensusAtlas: Australia’s Census, Made Easy to Explore
  • DecodeThis: One Tool to Parse Them All
  • Creating a full maps stack without Google
  • Strip all but certain characters from a string in PHP (such as alphanumeric, numeric, etc…)

Dr Helen Stallman, Clinical Psychologist

Proudly powered by WordPress | Theme: Understrap by understrap.com.(Version: 1.2.4)