You'll need to be more specific. First of all, you stated that the common name was in the form "(something)-disclose.gif". Do you really have parentheses in the common name? If so, you'll need to escape those in the regular expression. Further, what's allowed for the "something"? Is it all letters, are numbers allowed? Is punctuation allowed?

First advice: ignore what the Anonymous Monk said about using the dot star combination. It's slow and virtually guaranteed to break your code. See Death to Dot Star! for an explanation.

Here's a rough stab at your regular expression, assuming that the "something" cannot contain a dash:

# also assumes that the parentheses are not in the filename /<img # match the '<img' \s+ # must have one or more whitespace characters src # match the 'src' \s* # may have zero or more whitespace characters = # match the = \s* # may have zero or more whitespace characters [^-]+ # one or more non-dash characters -disclose.gif # rest of .gif name [^>]* # zero or more non-closing angle brackets >/ix # closing angle bracket

Cheers,
Ovid

Update: To whomever the Anonymous Monk is who criticized my regex: sign on and join us! That was a great catch and we could use more programmers like you!

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid) Re: Help with reg expressions by Ovid
in thread Help with reg expressions by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.