in reply to Re: regexp to return rest of string
in thread regexp to return rest of string

Humm... I seriously don't get it. And I don't mean to sound rude, but you're saying that you can reduce the two regex lines to one regex/ary line, but you can't figure out the regex itself? I'd have more trouble getting through the reduction than doing that simple regex. It just sounds fishy.

Is this a case of knowing a previous language before perl, or something of the sort?

That was a cool trick, btw.

#!/home/bbq/bin/perl
# Trust no1!
  • Comment on RE: Re: regexp to return rest of string

Replies are listed 'Best First'.
RE: RE: Re: regexp to return rest of string
by kirbyk (Friar) on Jun 03, 2000 at 02:00 UTC
    I figured out this trick (or actually a variant) just by lots of trial and error with regexs in my early perl days. I prefer using parentheses rather than array subscripts, eg:

    ($relative_url) = ($string =~ /content(.*)/);

    A _very_ useful version of this trick is with DBI, ie:

    $getStuff = $dbh->prepare("select id, price, info from mytable");
    $getStuff->execute();
    ($id, $price, $info) = $getStuff->fetchrow_array();
    I use this a ton.

    -- Kirby

    Tuxtops: Laptops with Linux!