Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Last active January 11, 2017 11:26
Show Gist options
  • Save james2doyle/7935407 to your computer and use it in GitHub Desktop.
Save james2doyle/7935407 to your computer and use it in GitHub Desktop.
Common Regex Snippets. Used for my github gist plugin in Sublime Text. It let's me fetch gists and put them in the clipboard.
Select Attribute (style in this case)
style\s*=\s*('|")(.*)('|")
Find Double Words (<the the> file)
\b(\w+)\b \1
HTML Tags - specific
<TAG\b[^>]*>(.*?)</TAG>
HTML Tags - vague
^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$
Emails
^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$
HEX codes
^#?([a-f0-9]{6}|[a-f0-9]{3})$
Slug (this-is-a-slug)
^[a-z0-9-]+$
URL
^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment