Hey, this works, just 1 thing it doesn't do, but should.

1) this.is.a.string.to.match.with
2) this.is.another.string.to.match.with
3) this.is.a.totally.with.different.string

I've changed string 3 just to demonstrate this. What I want to be able to
do, along with what's already been said, is to do a search for *.with and it
return only strings 1 and 2 (since they end in .with). String 3 contains
.with, but at the moment, this code returns that one as well.

Many thanks

Dan


"Rob Dixon" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Dan wrote:
> > Hi again,
> >
> > Yet another question for you. I string (these are just examples):
> >
> > 1) this.is.a.string.to.match.with
> > 2) this.is.another.string.to.match.with
> > 3) this.is.a.totally.different.string
>
>     use strict;
>     use warnings;
>
>     my @string = qw (
>         this.is.a.string.to.match.with
>         this.is.another.string.to.match.with
>         this.is.a.totally.different.string
>     );
>
> > Basically, what I want to be able to do, is to carry out match testing
> > against them, and return just the strings that match. For example, a
> > search of *.with returns strings 1 and 2
> > a search of *string* returns strings 1 and 2
> > a search of *a* returns all 3
> > a search of *.a.* returns 1 and 3
> > I think you should get the idea.
>
>     foreach my $pattern (qr(\.with), qr(string), qr(a), qr(\.a\.)) {
>         foreach my $i (0 .. $#string) {
>             print $i+1, " " if $string[$i] =~ $pattern;
>         }
>         print "\n";
>     }
>
> > I'm no master on regex, so I'd have absolutely no idea where to
> > start. All help muchly appreciated.
>
> Output:
>     1 2
>     1 2 3     (You see, 'string' appears in all 3 strings!)
>     1 2 3
>     1 3
>
> I'll explain tomorrow if you need me to. Bed time now :)
>
> Cheers,
>
> Rob
>
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to