How to get habr123 from a line like https://vk.com/habr123 ?
Closed due to the fact that the question is too common for the participants rjhdby , Denis , aleksandr barakin , HamSter , Hardc0re Oct 25 '16 at 15:34 .
Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .
3 answers
No regular expressions are needed here. Here you need to remove the first 15 characters from the source line.
/https?:\/\/(?:www\.)?(?:m\.)?vk\.com\/([a-zA-Z\d\._-]+)/ https?:\/\/ - this is https: // or http: //
(?:www\.)? - optional group without feedback corresponds to www.
(?:m\.)? - Optional group without feedback corresponds to m.
([a-zA-Z\d\._-]+) is the resulting group with the number 1, consisting of Latin characters, numbers, periods, underscores, and dashes, containing at least 1 character
Test https://regex101.com/r/a2ADdh/1
PS I don’t use contact, so I don’t know where they have it and how it is stored and called names.
Looking for the first entry point "/" from the end and delete everything in front of it, including "/"