develooper Front page | perl.beginners | Postings from April 2002

Re: grep

Thread Previous | Thread Next
From:
Sudarsan Raghavan
Date:
April 2, 2002 23:32
Subject:
Re: grep
Message ID:
3CAAAFE3.90F877E1@india.hp.com
Mandar Rahurkar wrote:

> Thanks  a million guys ....my prob is solved.
> Could you please tell me which are good references for regular expressions
> for perl ...

    You can start with
      perldoc perlretut
      perldoc perlre

>
>
> Many Thanks
> Mandar
>
> On Tue, 2 Apr 2002, John W. Krahn wrote:
>
> > Sudarsan Raghavan wrote:
> > >
> > > Mandar Rahurkar wrote:
> > >
> > > >   thanks to everyone for replying however I think i failed to define the
> > > > problem accurately :
> > > >
> > > > i have files assigned to @files variable :
> > > >
> > > > 2168a5_vow_band_1.fea
> > > > 169b2_vow_band_1.fea
> > > > 2168d6_vow_band_1.fea
> > > > 2168d5_vow_band_1.fea
> > > > 169g3_vow_band_1.fea
> > > > neutral.txt
> > > >
> > > > And i want the files say for eg suffix d and 1 and with extension fea.The
> > > > thing is if i try to match d all will get matched for obvious reason.
> > > >
> > > > basically I wanna generate the same output as of the following command on
> > > > shell prompt :
> > > > ls ???[g][^1] *.fea
> > > > ** will generate all files whose 4th char is g followed by character which
> > > > is not 1.
> > >
> > >     Loop through the array and check the value against this regexp
> > > m/.{3}g[^1].*\.fea/
> > >     If the array is being populated through some kind of file listing, my
> > > earlier suggestion
> > >     holds.
> >
> > Don't forget to anchor the regex at the beginning and end of the string:
> >
> > @files = grep /^.{3}g[^1].*\.fea$/, @files;
> >
> >
> > John
> > --
> > use Perl;
> > program
> > fulfillment
> >
> > --
> > To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> > For additional commands, e-mail: beginners-help@perl.org
> >
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About