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

Rory Winston Rory.Winston at telewest.co.uk
Fri Oct 25 14:29:07 IST 2002


Hi

I have a question re: a regex that has had me stumped. I have a CGI script
that generates a string of concatenated user ids, such as "1|2|86|907|7|"
etc. I had a regex that extracts the uids like so:

print("id=$1\n") while ( $id_string =~ /(\d+)|/g );

But this doesnt work - I always get an extraneous (empty) match for every
id, and an extra empty match at the end! Is this because it matches the '|'
character second time round or something?  it does work if I do:

print("id=$1\n") while ( $id_string =~ /(\d+)(|)/g );

I know, I know - RTFM for regexes - I have a copy of Friedl's "Mastering
Regular Expressions" on my shelf that I'm going to get around to reading one
of these days, but until then, can anyone shed any light?

Cheers
Rory

--------------------------------------------
Rory Winston,
Developer,
Internet Services,
Telewest Broadband,
Export House,
Woking,
Surrey
GU21 5RW

mailto: rory.winston at telewest.co.uk
phone:  01483 583358
mobile: 07985 807013

------------------------------------------------------------------------------
Live Life in Broadband
www.telewest.co.uk


The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material.
Statements and opinions expressed in this e-mail may not represent those of the company. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender immediately and delete the material from any computer.


==============================================================================




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