ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [RegEx] 정규식으로 이미지 url 체크 진행중
    NULL STACK 2021. 4. 19. 23:45
    반응형

    검색으로 찾은 url 정규식 가져와서 고쳐쓰기

    예시 링크

    https://www.naver.comhttps://naver.com

    www.naver.com/img/images/products/12345/13131313?ss_key=ASDF2QWERU.2QWER3M

    http://www.naver.comhttp://www.naver.com/img/images/products/12345/13131313?ss_key=ASDF2QWERU

    www.daum.co.kr/web/prod/small/202/221d7613b7935c4c30e4df13f.jpg

     

     

    정규식 고쳐가기

     

    (http(s)?\:\/\/)?([a-z0-9-:\w]+\.*)+[a-z0-9]{2,4}([\/])([\/a-z 0-9-%#?&\.=\w])*(\.[a-z]{2,4})*

     

    (http(s)?\:\/\/)?([a-z0-9-:\w]+\.*)+[a-z0-9]{2,4}(:[0-9])?([\/])([\/a-z 0-9-%#?&\.=\w])*(\.[a-z]{2,4})*

     

    (http(s)?\:\/\/)?([a-z0-9-:\w]+\.*)+[a-z0-9]{2,4}(:\d)?([\/])([\/a-z 0-9-%#?&\.=\w])*(\.[a-z]{2,4})*

     

    (http(s)?\:\/\/)?([a-z0-9-:\w]+\.*)+[a-z\d]{2,4}(:\d)?([\/])([\/ -%#?&\.=\w])*(\.[a-z]{2,4})?

     

    (http(s)?\:\/\/)?([-:\w]+\.*)+[a-z\d]{2,4}(:\d)?([\/ \-%#?&\.=\w])*

     


    https://www.naver.comhttps://naver.com  같이 똥같을때 

     

    정규식 고쳐가기

     

    앞부분 url만 매칭(뒤의 https까지 매칭되버림)

    (http(s)?\:\/\/)(?!\1)?([-:\w]+\.*)+[a-z\d]{2,4}(:\d)?([\/ \-%#?&\.=\w])*

     

    반응형
Designed by Tistory.