[^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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|