Help me write a JavaScript regular expression. Here’s what data should be skipped:
http://vk.com/user/
http://vk.com/user
vk.com/user/
vk.com/user
www.vk.com/user/
www.vk.com/user
It is clear that “user” is any text. It could also be “id123456”.
Answer 1, authority 100%
Here’s another working option:
^ (https?: \ / \ /)? (www \.)? vk \ .com \ / (\ w | \ d) +? \ /? $
Answer 2, authority 92%
^ (http: \ / \ / | https: \ / \ /)? (www.)? (vk \. com | vkontakte \ .ru) \ / (id \ d | [a-zA-Z0-9 _.]) + $
Answer 3
In fact, here’s a better solution
(https {0,1}: \ / \ /)? (www \.)? (vk.com \ / ) (id \ d | [a-zA-z] [a-zA-Z0-9 _.] {2,})
Since username cannot start with a number, like this: https://vk.com/1111111