Kendertaunt
Programmer
Hello!
I have tried so hard to do this on my own, now it's time to admit that I do not understand and see if someone can help! I did read FAQs on regular expressions, including goBoating's FAQ here on Tek-Tips. I think I am confused as to how to translate what I'm learning to my own example (which contains literal slashes - something else that's making me confused!)
Here's the thing. I'm pulling in a web site, getting it with no problem. I need to check the value of <img SRC>, which could be one of a few choices:
img src="/icons/sample1.gif"
img src="/icons/sample2.gif"
Basically, to make a short story long, , how do I test for the following:
/icons/sample[ANY NUMERIC CHARACTER].gif
I understand this is a really basic manuever in Perl. Believe me, I've tried everything. I think it has something to do with the fact that I'm not dealing with the fact that there are already literal slashes in there.
Here's some of the things I've tried:
if ($token->[1]{src} eq '/icons/sample[0-9]) {
or
if ($token->[1]{src} eq \/icons\/sample[\d]\.gif) {
or
my $IsIcon =~ \/icons\/sample(0-9)\.gif$/i ;
if ($token->[1]{src} eq $IsIcon) {
If someone could help me, I would LOVE to understand why everything I'm trying is just not working! It's not passing the If test.
If I hardcode it, it's fine. For example, this works:
if ($token->[1]{src} eq '/icons/sample1.gif') {
Thanks!
Jess
I have tried so hard to do this on my own, now it's time to admit that I do not understand and see if someone can help! I did read FAQs on regular expressions, including goBoating's FAQ here on Tek-Tips. I think I am confused as to how to translate what I'm learning to my own example (which contains literal slashes - something else that's making me confused!)
Here's the thing. I'm pulling in a web site, getting it with no problem. I need to check the value of <img SRC>, which could be one of a few choices:
img src="/icons/sample1.gif"
img src="/icons/sample2.gif"
Basically, to make a short story long, , how do I test for the following:
/icons/sample[ANY NUMERIC CHARACTER].gif
I understand this is a really basic manuever in Perl. Believe me, I've tried everything. I think it has something to do with the fact that I'm not dealing with the fact that there are already literal slashes in there.
Here's some of the things I've tried:
if ($token->[1]{src} eq '/icons/sample[0-9]) {
or
if ($token->[1]{src} eq \/icons\/sample[\d]\.gif) {
or
my $IsIcon =~ \/icons\/sample(0-9)\.gif$/i ;
if ($token->[1]{src} eq $IsIcon) {
If someone could help me, I would LOVE to understand why everything I'm trying is just not working! It's not passing the If test.
If I hardcode it, it's fine. For example, this works:
if ($token->[1]{src} eq '/icons/sample1.gif') {
Thanks!
Jess