Skip to content

Instantly share code, notes, and snippets.

@pgeraghty
Last active December 12, 2015 09:49
Show Gist options
  • Save pgeraghty/4754245 to your computer and use it in GitHub Desktop.
Save pgeraghty/4754245 to your computer and use it in GitHub Desktop.
Finding emails and URLs in MySQL columns
# contains email address
where("column_name REGEXP '[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]@[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]\.[a-zA-Z]{2,4}'").count
# contains url
where("column_name REGEXP ?", "(https?://|www\\.)[\.A-Za-z0-9\-]+\\.[a-zA-Z]{2,4}").count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment