regex - Could anyone give an explain on following javascript RE code? -
could give explain on following example code? it's last example here.
not sure why there's no '\'
before '.'
, can same result adding '\'
.
javascript:
var url = "http://xxx.domain.com"; print(/[^.]+/.exec(url)[0].substr(7)); // prints "xxx"
note paragraph here regarding metacharacters inside character classes
note special characters or metacharacters inside character class closing bracket (]), backslash (\), caret (^) , hyphen (-). usual metacharacters normal characters inside character class, , not need escaped backslash.
Comments
Post a Comment