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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -