Last active
March 9, 2021 16:41
-
-
Save FlyInk13/ed76d8a5a3e3605dac2985b83e3cc901 to your computer and use it in GitHub Desktop.
Регулярное выражение для вытаскивания screen_name из ссылки на пользователя
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vklink = /^(?:(?:https?\:\/\/)?(?:vk\.com\/)|\[)(.+?)(?:\|.+\]|$)/; // reg | |
console.log([ | |
"https://vk.com/flyink".match(vklink)[1], // flyink | |
"http://vk.com/flyink".match(vklink)[1], // flyink | |
"vk.com/flyink".match(vklink)[1], // flyink | |
"[id1|Павел Дуров]".match(vklink)[1], // id1 | |
"13123313".match(vklink) // null - не ссылка | |
]); // test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment