A worked example, rendered from real sample data. Sign in to run the tool on your own input.
^(?:https?:\/\/)?(?:www\.)?([\w-]+\.)+[\w]{2,}(?:\/[\w\-./?%&=]*)?$Pattern: /^(?:https?:\/\/)?(?:www\.)?([\w-]+\.)+[\w]{2,}(?:\/[\w\-./?%&=]*)?$/
Verdict: risky · 1 group(s), 3 character class(es), 8 quantifier(s), depth 1
Structure
→ ^ Start of the string
┌─ Group (not captured) (?:https?:\/\/)? ×? — optional (zero or one time)
→ http The text "http"
→ s? The text "s" ×? — optional (zero or one time)
→ : The text ":"
→ \/ The literal character "/"
→ \/ The literal character "/"
└─
┌─ Group (not captured) (?:www\.)? ×? — optional (zero or one time)
→ www The text "www"
→ \. The literal character "."
└─
┌─ Capture group 1 ([\w-]+\.)+ ×+ — one or more times
→ [\w-]+ Any one of: Any word character (a-z, A-Z, 0-9 or _), "-" ×+ — one or more times
→ \. The literal character "."
└─
→ [\w]{2,} Any one of: Any word character (a-z, A-Z, 0-9 or _) ×{2,} — 2 or more times
┌─ Group (not captured) (?:\/[\w\-./?%&=]*)? ×? — optional (zero or one time)
→ \/ The literal character "/"
→ [\w\-./?%&=]* Any one of: Any word character (a-z, A-Z, 0-9 or _), "-", ".", "/", "?", "%", "&", "=" ×* — zero or more times
└─
→ $ End of the string
Step by step
Start of the string
Group (not captured) [optional (zero or one time)]
The text "http"
The text "s" [optional (zero or one time)]
The text ":"
The literal character "/"
The literal character "/"
Group (not captured) [optional (zero or one time)]
The text "www"
The literal character "."
Capture group 1 — the matched text is kept for later [one or more times]
Any one of —
…
Visualize a regex as a railroad diagram with a plain-English breakdown. Part of the DevTools Surf developer suite. Browse more tools in the Developer Utilities collection.