Created
July 18, 2018 13:01
-
-
Save ifirmawan/6aa1435aee68f604b40558d6dc8ef017 to your computer and use it in GitHub Desktop.
Regex to delete all words containing numbers from a sentence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$str = 'This is S3F8G m7j34m h98H40D-3D39 90843-432423 LSDF3 4X4it very good 343c3.';; | |
preg_match_all("/(^[\D]+\s|\s[\D]+\s|\s[\D]+$|^[\D]+$)+/",$str,$result); | |
$result = implode('',$result[0]); | |
echo $result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment