Help create a regular javascript expression. Here is what data should be passed:
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 may also be "id123456".
Help create a regular javascript expression. Here is what data should be passed:
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 may also be "id123456".
Here is another working version:
^(https?:\/\/)?(www\.)?vk\.com\/(\w|\d)+?\/?$
^(http:\/\/|https:\/\/)?(www.)?(vk\.com|vkontakte\.ru)\/(id\d|[a-zA-Z0-9_.])+$
\d{9})
. The result: (http:\/\/|https:\/\/)?(www.)?(vk\.com|vkontakte\.ru)\/(id(\d{9})|[a-zA-Z0-9_.]+)
. Demonstration - regex101.com/r/mB9aK1/1 . Thank. - Sasha ChernykhActually, here's the solution.
(https{0,1}:\/\/)?(www\.)?(vk.com\/)(id\d|[a-zA-z][a-zA-Z0-9_.]{2,})
Since the username cannot begin with a number, for example: https://vk.com/1111111
s{0,1}
it better to write s?
. - Vadim OvchinnikovSource: https://ru.stackoverflow.com/questions/125011/
All Articles