$FILTOK

By SyntaxIRC on Mar 07, 2008

Usage: $filttok(TOKEN,RANGE,C)
Example: $filttok(a.b.c.d.e,b-c,46) will return a.d.e

As you can see, it works for both letters and numbers and will filter out the range.

alias filtok {
  var %x = 1, %ftok = $1
  while %x <= $numtok($1,$3) {
    var %ftok = $iif($regex($gettok($1,%x,$3),/[ $+ $2 $+ ]/i),$remtok(%ftok,$gettok($1,%x,$3),1,$3),%ftok)
    inc %x
  }
  return %ftok
}

Comments

Sign in to comment.
^Neptune   -  Aug 31, 2008

Hmmm yeah. Maybe it would be good so the user could specify letters to filter via a comma, and recognise the last parameter used as the token.

Because if you use d-e for example that's like a range. I mean, what if you wanted to filter "a" and "z" together? You'd filter and get rid of the entire string!

 Respond  
Scakk   -  Aug 31, 2008

True.

However I used

//echo -ag $filtok(a.d.r.e.t.e.d.s,d-e,46)

and got left with only "a" when it should have been "a.r.t.s" yes?

 Respond  
^Neptune   -  Aug 31, 2008

Kind of, but it deletes any occurence of the letter.

 Respond  
Scakk   -  Aug 31, 2008

This looks alot like $deltok

From /help

$deltok(text,N-N2,C)

Deletes the Nth token from text.

$deltok(a.b.c.d,3,46)        returns a.b.d
$deltok(a.b.c.d,2-3,46)        returns a.d

You can specify a negative value for N.
 Respond  
^Neptune   -  Aug 18, 2008

Nice
This has been criminally overlooked >:[

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.