javascript - Get current matching regex-rule -


i try check given regexp-rule in string , need current matching rule.

here's i've tried far:

var prefixes = /-webkit-|-khtml-|-moz-|-ms-|-o-/g; var match; var str = '';  while ( !(match = prefixes.exec(str)) ) {     str += '-webkit-';     console.log(match); // => null } 

the match null, how can current matching-rule (in case -webkit-)?

you aren't asking groups in regex, try surrounding regex in parenthesis define group, e.g. /(-webkit-|-khtml-|-moz-|-ms-|-o-)/g.

various other issues, try:

var prefixes = /(-webkit-|-khtml-|-moz-|-ms-|-o-)/g; var match; var str = 'prefix-ms-something';  match = prefixes.exec(str); console.log(match); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -