regex - Javascript Reg Exp number in brackets -


if (!$is.ie5) {     v = (ua.tolowercase().match(new regexp(".+(?:rv|it|ra|ie)[\\/: ]([\\d.]+)"))||[])[1]; } 

what [1] mean in reg expression??

it array deference on answer.

v = (ua.tolowercase().match(new regexp(".+(?:rv|it|ra|ie)[\\/: ]([\\d.]+)"))||[])[1]; 

the deference [1] applied function result, first matched group (groups delimited parentheses ()).

so v = first group match of (ua.tolowercase().match(new regexp(".+(?:rv|it|ra|ie)[\\/: ]([\\d.]+)"))||[]).

note ||[] @ end allows no matches not give error.

this first group match ([\\d.]+) group, first parentheses not stored due (?:...) non-matching group construct.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -