Last active
January 11, 2017 11:26
-
-
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.
This file contains hidden or 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
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