Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tallesairan/23286636e48647ee0fa7059e2f4182a3 to your computer and use it in GitHub Desktop.
Save tallesairan/23286636e48647ee0fa7059e2f4182a3 to your computer and use it in GitHub Desktop.
Remove texts and emails from string
<?php
function removeDomainsFromString($string){
return trim( preg_replace('/[a-zA-Z]*[:\/\/]*[A-Za-z0-9\-_]+\.+[A-Za-z0-9\.\/%&=\?\-_]+/i','',preg_replace('/[^@\s]*@[^@\s]*\.[^@\s]*/', '',$string)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment