[ic] help pulling info from URL

Kevin Walsh interchange-users@icdevgroup.org
Sat Nov 2 08:46:00 2002


Grant [listbox@email.com] wrote:
> >
> > [perl]
> >     @{$Scratch}{'pstn2','pstn3'} = (split('/',$Session->{last_url}))[2,3];
> >     $Scratch->{pstn3} =~ s/(.*?)\.html?/$1/;
> > [/perl]
> >
> > [scratch pstn2], [scratch pstn3]
> >
> Thanks Ryan, that removes the .html put not the p.  I need just the number.
> I need to turn "p1.html" into just "1" or "p99.html" into "99".  Almost
> there....
> 
You could strip all non-numerics with:

    $Scratch->{pstn3} =~ s/\D//g;

That will turn "p123.html" into "123" but will also turn "1p234a56.html"
into "123456".

If your format is specifically "character + numeric(s) + characters"
then you could use this:

    $Scratch->{pstn3} =~ s/^\D(\d+).*/$1/;

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin@cursor.biz
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/