Javascript Regex multiple group matches in pattern -


I have a question for a javascript regex ninja: how do I build my variable from a string using regex grouping Can I simplify? I am currently working without using any group, but it would be nice to see me in a better way!

is the string:

  var url = 'resources / css / main? .css detection = # card {width: 300px;} ';  

The code that works:

  var styleStr = / [^ =] + $ / / Exec (url) .toString (); Var id = / [^ \ #] [^ \ {] + / Exec (styleStr) .toString (); Var Properties = / [^ \ {] + /. Exec (/ [^ \ # \ w] [^ \:] + /.exec (styleStr)). ToString (); Var value = / [^ \:] + /. Exec (/ [^ \ # \ w \ {] [^ \:] + [^ \; \}] /. Exec (styleStr). ToString ();  

gives:

  warning (id) // information information (property) // width warning (value) // 300px  

Any buyer?

Sure ..

  var url = 'resources / css / Main.css? Locate = # info {width: 300px;} '; Var matches = url.match (/ # ([^ {] +) {([^:] +): ([^;] +) /); Var id = match [1]; Var Properties = Match [2]; Var value = match [3];  

Comments