JAVA언어

http url 정규식으로 파싱하기 (페턴)

천상의날개 2022. 8. 23. 14:18

Pattern p = Pattern.compile("^(https?):\\/\\/([^:\\/\\s]+)(:([^\\/]*))?((\\/[^\\s/\\/]+)*)?\\/([^#\\s\\?]*)(\\?([^#\\s]*))?(#(\\w*))?$"); 
Matcher m =p.matcher(url);
if(m.find()) {
    m.group(1);
    m.group(2);
}

 

참조 : https://goodidea.tistory.com/86