M
M
MarkJSexton2020-06-23 17:41:10
JavaScript
MarkJSexton, 2020-06-23 17:41:10

How to strip source name using Regex?

I need to strip the source name from the url, there could be things like this:

https://domen.site.ru/podsait/03285926/#2412747495
http://www.site.ru/site/24722305
https://www.domen.site.ru/site/rss
https://www.поддомен.сайт.рф/
site.ru


You need to cut out only "site" or if in Cyrillic, then "site".
How can this be done with a single regex line?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-06-23
@MarkJSexton

str.match(/[^.]+(?=\.[^.]+(\/|$))/)[0]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question