Phoenix.pm: Regex question

Phil Hartfield chaosppp at corp.earthlink.net
Mon Feb 5 16:36:24 CST 2001


Heh, had to look that up in the <HREF="http://info.astrian.net/jargon/">Jargon
Dictionary</A>  

TMTOWTDI, MBIIYS CTLB

Phil Hartfield
 ________
/        \
|GoStats |
|        |
| R.I.P. |
|        |
|Dec 2000|
----------

Doug Miles wrote:
> 
> Anthony Nemmer wrote:
> > 
> > Jesus, Doug.  =)
> 
> Sorry.  That wasn't what I meant.  I was just saying TMTOWTDI and
> welcome to the mailing list!
> 
> > At 01:07 PM 2/5/01 -0700, you wrote:
> > >tcpeter at mindspring.com wrote:
> > >>
> > >> On Fri, 2 Feb 2001, Doug Miles wrote:
> > >>
> > >> > This is probably something obvious,
> > >>
> > >> I don't think so...
> > >>
> > >> > but I don't have my regex book with
> > >> > me, and can't seem to figure it out.  I'm trying to parse space
> > >> > delimited information, somewhat like the UNIX command line.  Whitespace
> > >> > delimits parameters, but parameters can containg whitespace if
> > >> > surrounded by quotes.  Here's the code:
> > >> >
> > >> > #!/usr/bin/perl
> > >> >
> > >> > my $string = qq(DailyNAV "Class C" nav);
> > >> >
> > >> > my @tokens = $string =~ /(\S+)/g;
> > >> > my @tokens = $string =~ /"([^"]+)"/g;
> > >>
> > >> > my @tokens = $string =~ /"([^"]+)"|(\S+)/g;
> > >> > print join('|', @tokens) . "\n";
> > >> >
> > >> > here is the output:
> > >> >
> > >> > DailyNAV|"Class|C"|nav
> > >> > Class C
> > >> > |DailyNAV|Class C|||nav
> > >>
> > >> Doug,
> > >> I've been sorta lurking here a long time reading, but this is the first
> > time I've contributed.  This seems to work.  It's really the same as one of
> > yours, with just a bit of tweaking.
> > >
> > >I'll be nice since you're a first time poster. :)
> > >
> > >>
> > >> #!/usr/bin/perl
> > >>
> > >> my $string = qq(DailyNAV "Class C" nav);
> > >> print join('|', split(/\s?"([^"]+)"\s?/, $string))."\n";
> > >
> > >--
> > >- Doug
> > >
> > >Encrypted with ROT-26 - all attempts to decrypt are illegal under the
> > >DMCA!
> > >
> > >
> 
> -- 
> - Doug
> 
> Encrypted with ROT-26 - all attempts to decrypt are illegal under the
> DMCA!
> 




More information about the Phoenix-pm mailing list