I am trying to use Perl to search through an html file, looking for a semi-random string and store the match in a variable or print it out.
The string is the name of a jpg image and always follows the pattern of 9 digits followed by 6 lower case letters, i.e.
140005917smpxgj.jpg
But it is random every time. I am sure Perl can do this, but I will admit I am getting a bit confused.
Not too complicated. You may want to watch out for varying caps in the extension, e.g.
JPG. If that is a concern, you may add(?i)before the extension.You may also wish to prevent partial names, e.g. discard a match that has more than 9 digits. That is the
(?<!\d)part: Make sure no digit characters precede the match.ETA: Now extracts multiple matches too, thanks to ikegami.