Regular Expressions 101

JavaScript Parse CSS Selector

Open Workspace
  • JavaScript
  • Match
0

Regular Expression

/
^(.*?)(?:#(.*?))?(?:\.(.*))?$
/
gm

Description

Parse CSS Selector in the form element#id.class into its components. Any of the three elements can be missing.

Submitted by Mark