Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Extract Parren matched values

Reply
Thread Tools

Extract Parren matched values

 
 
ansher
Guest
Posts: n/a
 
      03-23-2009
Hello

I have a file which looks something like this...

l axn1;c=c(&dat)'&lnk';nz
*include &tt.qin;tt=WEB
*include &base.qin;
*include q6.qin;
*include q7.qin; axn=q7;col(b)=&kod;pun=&p;fil=&fb
*include q8.qin; axn=q8;col(b)=&qod;pun=&p;fil=&fb
n01&txt ;c=gkeeper.eq.1
n01Not &txt ;c=gkeeper.eq.2

I want a list of values which qualifies the condition m/\&[a-z]+/.

It will be great if you can help me in how to get the exact pattern
match values to an array.


&dat
&lnk
&tt
&base
&kod
&p
&fb
&qod
&txt


 
Reply With Quote
 
 
 
 
Tad J McClellan
Guest
Posts: n/a
 
      03-23-2009
ansher <> wrote:


> I have a file which looks something like this...


[snip]

> I want a list of values which qualifies the condition m/\&[a-z]+/.
>
> It will be great if you can help me in how to get the exact pattern
> match values to an array.



----------------
#!/usr/bin/perl
use warnings;
use strict;

my @ampersands;
while ( <DATA> ) {
push @ampersands, /(&[a-z]+)/g;
}
print "$_\n" for @ampersands;


__DATA__
l axn1;c=c(&dat)'&lnk';nz
*include &tt.qin;tt=WEB
*include &base.qin;
*include q6.qin;
*include q7.qin; axn=q7;col(b)=&kod;pun=&p;fil=&fb
*include q8.qin; axn=q8;col(b)=&qod;pun=&p;fil=&fb
n01&txt ;c=gkeeper.eq.1
n01Not &txt ;c=gkeeper.eq.2
----------------


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
 
Reply With Quote
 
 
 
 
sln@netherlands.com
Guest
Posts: n/a
 
      03-23-2009
On Mon, 23 Mar 2009 08:37:47 -0700 (PDT), ansher <> wrote:

>Hello
>
>I have a file which looks something like this...
>
>l axn1;c=c(&dat)'&lnk';nz
>*include &tt.qin;tt=WEB
>*include &base.qin;
>*include q6.qin;
>*include q7.qin; axn=q7;col(b)=&kod;pun=&p;fil=&fb
>*include q8.qin; axn=q8;col(b)=&qod;pun=&p;fil=&fb
>n01&txt ;c=gkeeper.eq.1
>n01Not &txt ;c=gkeeper.eq.2
>
>I want a list of values which qualifies the condition m/\&[a-z]+/.
>
>It will be great if you can help me in how to get the exact pattern
>match values to an array.
>
>
>&dat
>&lnk
>&tt
>&base
>&kod
>&p
>&fb
>&qod
>&txt
>


-sln

use strict;
use warnings;

my @vals = join('', <DATA>) =~ /\&[a-z]+/g;
print "@vals\n";


 
Reply With Quote
 
ansher
Guest
Posts: n/a
 
      03-23-2009
On Mar 23, 11:08*pm, Tad J McClellan <ta...@seesig.invalid> wrote:
> ansher <Anshe...@gmail.com> wrote:
> > I have a file which looks something like this...

>
> [snip]
>
> > I want a list of values which qualifies the condition m/\&[a-z]+/.

>
> > It will be great if you can help me in how to get the exact pattern
> > match values to an array.

>
> ----------------
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> my @ampersands;
> while ( <DATA> ) {
> * * push @ampersands, /(&[a-z]+)/g;}
>
> print "$_\n" for @ampersands;
>
> __DATA__
> l axn1;c=c(&dat)'&lnk';nz
> *include &tt.qin;tt=WEB
> *include &base.qin;
> *include q6.qin;
> *include q7.qin; axn=q7;col(b)=&kod;pun=&p;fil=&fb
> *include q8.qin; axn=q8;col(b)=&qod;pun=&p;fil=&fb
> n01&txt * * * * * * * * * * * * * * * * * * * * * * *;c=gkeeper.eq.1
> n01Not &txt * * * * * * * * * * * * * * * * * * *;c=gkeeper.eq.2
> ----------------
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


Thanks a lot
 
Reply With Quote
 
ansher
Guest
Posts: n/a
 
      03-23-2009
On Mar 23, 11:32*pm, s...@netherlands.com wrote:
> On Mon, 23 Mar 2009 08:37:47 -0700 (PDT), ansher <Anshe...@gmail.com> wrote:
> >Hello

>
> >I have a file which looks something like this...

>
> >l axn1;c=c(&dat)'&lnk';nz
> >*include &tt.qin;tt=WEB
> >*include &base.qin;
> >*include q6.qin;
> >*include q7.qin; axn=q7;col(b)=&kod;pun=&p;fil=&fb
> >*include q8.qin; axn=q8;col(b)=&qod;pun=&p;fil=&fb
> >n01&txt * * * * * * * * * * * * * * * * * * * * * * *;c=gkeeper.eq.1
> >n01Not &txt * * * * * * * * * * * * * * * * * * *;c=gkeeper.eq.2

>
> >I want a list of values which qualifies the condition m/\&[a-z]+/.

>
> >It will be great if you can help me in how to get the exact pattern
> >match values to an array.

>
> >&dat
> >&lnk
> >&tt
> >&base
> >&kod
> >&p
> >&fb
> >&qod
> >&txt

>
> -sln
>
> use strict;
> use warnings;
>
> my @vals = join('', <DATA>) =~ /\&[a-z]+/g;
> print "@vals\n";- Hide quoted text -
>
> - Show quoted text -


Thanks a lot
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compare 2 data files and extract fields for matched lines shree Perl Misc 5 12-29-2007 09:45 PM
How do i extract vidios when winrar wont extract them??? help plzzzzzzzz smuttdog@sc.rr.com Computer Support 2 12-23-2007 07:03 AM
Remembering Matched Values nicolas_laurent545@hotmail.com Perl Misc 2 08-05-2005 06:41 PM
matched delays in Xilinx ISE? David Tweed VHDL 0 05-26-2005 08:39 PM
VHDL Matched Filter Patrick VHDL 1 07-06-2004 10:07 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57