Skip to content

Instantly share code, notes, and snippets.

@emilbayes
Created May 11, 2016 08:26
Show Gist options
  • Save emilbayes/ba8e4301c0f1981a1b405190d7ec80eb to your computer and use it in GitHub Desktop.
Save emilbayes/ba8e4301c0f1981a1b405190d7ec80eb to your computer and use it in GitHub Desktop.
CSS Selector for HTML RegExp
^([a-z]+)? #Element
(?:(\.-?[_a-zA-Z]+[_a-zA-Z0-9-]*)| #classes
(?:#[A-Za-z][-A-Za-z0-9_:.]*)| # Id
(\[[a-zA-Z-]+(?:=["']?.*["']?)?\]))* #Attribute
(\{.*\})? #Text Content
html
.class
#id
section.class
input[type=text][disabled].class#id{hello}
input.class[type=text]#id[disabled]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment