mIRC Home    About    Download    Register    News    Help

Print Thread
#28260 05/06/03 07:27 AM
S
ScatMan
ScatMan
S
it would be nice a new identifier $regtok that the separator will be a regular expression, like:
$regtok(blah1bla2test,2,\d)
the separator is a digit so it will return bla
$regtok(asfjlasfOsfjkahsfjasPsafjsahfkj,0,[A-Z])
will return 3..
etc


#28261 05/06/03 12:49 PM
Joined: Feb 2003
Posts: 2,737
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,737
nifty idea. It should be able to include multiple characters even. You could simplify so many regular expressions this way, without cumbersom back-references.

$regtok(abc...def...ghi,1,/\.{3}/)
$regex(abc...def...ghi,/(.*?)\.{3}|\.{3}(.*?)/g) ... $regml(1)
Actually, that expression wont work without a \G or pos() somewhere, but I can't figure it out right now.
it's only returning 'abc' and 'def' but not 'ghi'. frown

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#28262 05/06/03 02:11 PM
Joined: Jan 2003
Posts: 247
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 247
mIRC snippets made by a friend of mine:

$twildtok() http://scriptsdb.org/comments.php?id=98

$regtok() http://scriptsdb.org/comments.php?id=99

$tregtok() http://scriptsdb.org/comments.php?id=100

The t* versions are used in an inverse manner where the paterns are the token string and you want to verify which patern matchs the given token.


#28263 05/06/03 02:13 PM
Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Meanwhile, you can use this simple alias:
Code:
alias regtok {
  !.echo -q $regex(rgt,$1,/(?(?! $+ $3 $+ )(.+?))(?: $+ $3 $+ |$)/g)
  if $2 < 0 { return $regml(rgt,$iif($calc($regml(rgt,0) + 1 + $2) > 0,$ifmatch)) }
  return $regml(rgt,$2)
}
It doesn't support token ranges (eg $regtok(<input>,1-3,<regex>) ) but it supports negative tokens. It's very possible to make it support ranges (by using the .pos property in $regml()) but it gets kinda slower and I won't attempt to make it unless you need it.

#28264 05/06/03 02:17 PM
S
ScatMan
ScatMan
S
uh thanks


Link Copied to Clipboard