내 URL이정규식 도움말 -
https://foo.bar.com/somedirectory/somefile.php
또는http://abc.bar.co.uk/somedirectory/somefile.php
/somedirectory/somefile.php
또는
이somedirectory/somefile.php
?use strict; use warnings; my @urls=("https://foo.bar.com/somedirectory/somefile.php", "http://abc.bar.co.uk/somedirectory/somefile.php"); foreach my $url(@urls) { if($url=~/^http(?:s)?:\/\/[^\/]+(\/.*)$/) { print "$1\n"; } else { print "$url did not match!\n"; } }
출력은 다음과 같습니다
를 사용할 수 있을까? 이 언어는 URI를 구문 분석하는 기능을 제공합니다. –
"regex url"을 여기에서 찾으십시오. 수락 된 답을 가진 12 가지 이상의 질문이있을 것입니다. 참고로 ... url을 구문 분석하기 위해 선택한 언어로 주어진 메서드를 사용해야합니다. – pcalcao
[URL에서 호스트 이름과 포트를 제거하는 정규식?] (http://stackoverflow.com/questions/441755/regular-expression-to-remove-hostname-and-port-from-url)의 가능한 복제본 –