Non-Capturing Group (Image URL) in PY
Use non-capturing groups `(?:...)` to alternate without polluting the captured-groups list.
Try it in the PY tester →Pattern
regexPY
(?:https?:\/\/)\S+\.(?:jpg|jpeg|png|gif|webp|svg) (flags: gi)Python (re) code
pyPython
import re
pattern = re.compile(r"(?:https?:\/\/)\S+\.(?:jpg|jpeg|png|gif|webp|svg)", re.IGNORECASE)
input_text = "Logo at https://example.com/logo.png and https://cdn.io/img.svg"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
How the pattern works
(?:https?:\/\/) groups the protocol options without capturing them — useful when you only care about matching, not extracting. \S+ matches the non-whitespace URL body. \.(?:jpg|jpeg|png|gif|webp|svg) matches the dot and extension via another non-capturing group. The pattern has zero capture groups; switch to `(...)` if you need to extract pieces.
Examples
Input
Logo at https://example.com/logo.png and https://cdn.io/img.svgMatches
https://example.com/logo.pnghttps://cdn.io/img.svg
Input
http://insecure.test/photo.JPEGMatches
http://insecure.test/photo.JPEG
Input
ftp://old/asset.pngNo match
—