mIRC Home    About    Download    Register    News    Help

Print Thread
#109765 01/02/05 06:12 AM
Joined: Dec 2002
Posts: 79
F
Fantas Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: Dec 2002
Posts: 79
i have been trying to get the last 2 words from something like this http://www.website.com/pic.jpg
used $gettok(1,4,47) and mixed the numbers around a lot. and sometimes it works, but if diff folders on the website sometimes i get com/pic.jpg
is it $matchtok i need to do or what?

#109766 01/02/05 06:28 AM
Joined: Dec 2004
Posts: 81
N
Babel fish
Offline
Babel fish
N
Joined: Dec 2004
Posts: 81
The reason this is failing is because you're searching for a forth instance (token) of 47 (/) which isnt found since http://www.website.com/pic.jpg only contains three / tokens. Which returns nothing or $null. Anyways here's an example:

Code:
alias getlocation {
  if ($regex($1,^(http://|ftp://|https://)) && $count($1,/)) {
    return $gettok($1,3-,47)
  }
}


//echo -a $getlocation(http://www.website.com/pic.jpg)
returns pic.jpg

If you need more explaining and/or details just let me know.

Last edited by nycdiesel; 01/02/05 06:29 AM.
#109767 01/02/05 07:30 AM
Joined: Sep 2003
Posts: 4,214
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,214
are you just trying to get the filename ? if so $gettok(text,-1,47)

#109768 01/02/05 10:00 AM
Joined: Dec 2002
Posts: 79
F
Fantas Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: Dec 2002
Posts: 79
Thanks guys, yeah Davec that worked


Link Copied to Clipboard