Getting parts of a URL (Regex)

后端 未结 26 2208
说谎
说谎 2020-11-22 02:13

Given the URL (single line):
http://test.example.com/dir/subdir/file.html

How can I extract the following parts using regular expressions:

  1. The Subd
26条回答
  •  礼貌的吻别
    2020-11-22 02:49

    Java offers a URL class that will do this. Query URL Objects.

    On a side note, PHP offers parse_url().

提交回复
热议问题