This question has already been answered:

Have url

_http: //domen.com/name

It is necessary to extract part:

_http: //domen.com/ name

Help create a regular expression.

Reported as a duplicate by Visman participants, Vladimir Martyanov , Sergey Snegirev , aleksandr barakin , tutankhamun Sep 1 '15 at 12:46 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • 3
    parse_url does not help, since regular is needed? It is even easier to go: select all that to the right of the last '/'. - Vladimir Martyanov
  • four
    Possible duplicate question: Parsing a URL with parse_url - Visman

1 answer 1

Instead of a regular expression, it is better to use the parse_url function. It will be much easier than messing with regular expressions.

To get the path from the URL, you can use the following code:

 echo(parse_url($url, PHP_URL_PATH));