in reply to Regex to match non image urls
[^jpg] is a character class - meaning you match either j, p, org.
Update: and the ^ negates the character class, so [^jpg] matches a single character that is not j, p, or g.
Other than that, I feel your list is incomplete. Why won't you allow .svg images?
And are you aware that it's completely possible to write a script in, say some CGI capable language such as Perl indeed, that would be called my-image-script.(txt|html|bananajuice) that would still generate a valid image in whatever format? But your regexp would disallow it. Is that intentional?
Anyway, this should help you along...
m( \[img\] # Match opening tag \s* # Maybe there are spaces inside .*? # Non-greedy match \. # A dot (?: # Non-capturing group jpe?g | png | svg | gif | bmp ) # End of group \s* # Maybe there are more spaces still \[/img\] # Match closing tag )x
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex to match non image urls
by userdefinable (Initiate) on Jan 18, 2013 at 09:29 UTC | |
by userdefinable (Initiate) on Jan 18, 2013 at 09:36 UTC | |
by Anonymous Monk on Jan 18, 2013 at 10:01 UTC | |
by userdefinable (Initiate) on Jan 18, 2013 at 10:11 UTC | |
by userdefinable (Initiate) on Jan 18, 2013 at 10:16 UTC | |
by muba (Priest) on Jan 18, 2013 at 11:19 UTC | |
by userdefinable (Initiate) on Jan 18, 2013 at 10:06 UTC | |
by Anonymous Monk on Jan 18, 2013 at 10:14 UTC |