A
A
artloveyou2021-06-23 18:57:01
Regular Expressions
artloveyou, 2021-06-23 18:57:01

How to separate protocol and host from url using regular expression?

There is https://www.site.com/en/
It is necessary to cut off /en/
To get https://www.site.com

But the options themselves may be different There are https://www.site.com/ru/ , https ://www.site.com/de/ , https://www.site.com/in/
Or maybe https://www.ar.site.com - in this case nothing is cut off

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-06-23
@artloveyou

With regular expressions, you can:
https?:\/\/[^\/]*

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question