LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Perl regex question

[ILUG] Perl regex question

Niall O Broin niall at magicgoeshere.com
Thu Oct 19 19:01:54 IST 2000


On Thu, Oct 19, 2000 at 06:04:29PM +0100, Dermot McGahon wrote:

> Can MB1 and MB2 be contained within <data>. If not then you should
> just use the fact that they are always there and match up to them.

They can, in principle, but they never will be, in practice.

> Untested. If you send on sample data I will test this or other
> solutions I may come up with:
> 
>  while (/$MB1$MB2(.)..(.*)(?!$MB1$MB2)/) { $data{$1} = $2 }

This is a nice Perlish solution, but unfortunately it won't work because the
last <data> won't have MB1,MB2 after it :-( 

I ended up using something like this

while ($buffer =~ /($MB1$MB2)([$markers])(..)/g) {
  $length = unpack("n", $3);
  $item = $2;
  $buffer =~ /(.{$length})/g;
  $data{$item} = $1;
}

but I really had hoped that I could mangle the two regex and the length
calculation into one regex - apparently it may be possible in 5.6.




Regards,


Niall




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell