Text Processingflags: gi
Non-Capturing Group (Image URL)
Use non-capturing groups `(?:...)` to alternate without polluting the captured-groups list.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("(?:https?:\\/\\/)\\S+\\.(?:jpg|jpeg|png|gif|webp|svg)", "gi");
const input = "Logo at https://example.com/logo.png and https://cdn.io/img.svg";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
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+.
Go (RE2) code
goGo
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`(?i)(?:https?:\/\/)\S+\.(?:jpg|jpeg|png|gif|webp|svg)`)
input := `Logo at https://example.com/logo.png and https://cdn.io/img.svg`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
regexengine-agnostic
(?:https?:\/\/)\S+\.(?:jpg|jpeg|png|gif|webp|svg) (flags: gi)Raw source: (?:https?:\/\/)\S+\.(?:jpg|jpeg|png|gif|webp|svg)
How it 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
—Common use cases
- •Cleaner regex that avoids stray groups
- •Performance-sensitive matching (capturing has cost)
- •Refactoring patterns where you don't need the group's value
- •Building composable regex fragments
Related patterns
Named Capture Group (Date)
Text ProcessingDemonstrate named capture groups by extracting year/month/day from ISO-style dates.
Non-ASCII Character
Text ProcessingMatch runs of non-ASCII characters (anything outside U+0000–U+007F).
Lazy / Non-Greedy Quantifier
Text ProcessingDemonstrate lazy quantifiers `+?` by matching the SHORTEST HTML-like tag rather than the longest greedy span.
Markdown Image
Text ProcessingMatches Markdown image syntax .