in reply to Re: Re: Newbie reg.exp question!
in thread Newbie reg.exp question!

Hi again, Thanks anyway, but I found a working solution my self. Like this:

(@instances) = $line =~ m/[A-Z]{2}\d{11}/g; foreach $elem (@instances) { print $elem . ","; }

It gives me every occurance of the substring in the string.
BR,
Rune

Replies are listed 'Best First'.
Re: Re: Re: Re: Newbie reg.exp question!
by RuneK (Sexton) on Dec 16, 2002 at 15:01 UTC
    Help again,
    My script just evolved. Now I need to support an extend string that looks like this:

    C[CCNNNNNNNNNNN] C= Char N= Number
    The former solution looked like this:

    @list = $line =~ m{ ( [A-Z]{2}\d{11} ) }gx;
    How can I support the special characters in the string? I tried like this, but it didn't return anything:

    @list = $line =~ m{ ( [A-Z]{1}\[[A-Z]{2}\]\d{11} ) }gx;
    Could someone please help and explain me how to do it correctly so that I don't have to ask next time?


    Thanks,
    Rune