tool::regex-guide
regex url
/^https?:\/\/[^\s\/$.?#].[^\s]*$/i
URL 주소 검증
정규식 패턴
/^https?:\/\/[^\s\/$.?#].[^\s]*$/i
플래그:
i패턴 분석
^https?http or https scheme:\/\/Literal ://[^\s\/$.?#]First domain char: not whitespace, slash, dot, $, ?, #.Any single character[^\s]*Rest of URL: any non-whitespace characters$End of string매칭 예시
✓
https://example.com✓
http://sub.domain.org/path?q=1✓
https://api.site.io/v1/users비매칭 예시
✗
ftp://file.server.com✗
example.com✗
https://✗
//no-scheme.comhttp 또는 https 프로토콜로 시작하는 URL을 검증하는 패턴입니다. 도메인, 경로, 쿼리스트링 등 일반적인 URL 구성 요소를 허용합니다. ftp나 mailto 같은 다른 스킴은 별도 패턴이 필요합니다.
언어별 사용법
주요 사용 사례
- ▸웹사이트 URL 입력 필드 검증
- ▸링크 목록에서 유효한 URL 필터링
- ▸크롤러의 URL 형식 사전 검증
- ▸사용자 프로필 홈페이지 URL 검증
- ▸API 웹훅 URL 등록 전 유효성 확인
관련 패턴
ad · 300×250
// related tools