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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |