mIRC Homepage
Posted By: CloCkWeRX Regex Tokenizing - 27/07/03 04:25 PM
Now it's entirely possible to script, but could turn out to be a bit bothersome; but I think I could find being able to tokenize something by a regexp would be handy-dandy.

SURE you may say we have it already; but thats in 3 or 4 lines of code and testing. I just don't have the finger muscles to type that much.

/tokenize -r <regexp> <text>
Posted By: codemastr Re: Regex Tokenizing - 27/07/03 05:06 PM
Not 100% sure what that would do. Something like turn \1 \2 \3 into $1 $2 $3? ie, all the backreferences become identifiers?
Posted By: CloCkWeRX Re: Regex Tokenizing - 28/07/03 09:49 AM
Its more of a nicety than anything else:

It'd provide similar functionality to preg_split() as used in PHP
http://au.php.net/manual/en/function.preg-split.php

*repastes a tiny bit for the lazy*
array preg_split ( string pattern, string subject [, int limit [, int flags]])

Returns an array containing substrings of subject split along boundaries matched by pattern.

Posted By: codemastr Re: Regex Tokenizing - 28/07/03 03:41 PM
Ah, then yeah, that would be useful to have. Although, mIRC will force some of the nice features (such as the offset of each token) to be lost...
Posted By: Clubfoot Re: Regex Tokenizing - 04/08/03 12:04 AM
regex is taken from perl..if perl doesnt support that then regex on mIRC never will
Posted By: codemastr Re: Regex Tokenizing - 04/08/03 02:36 AM
Umm no, you're totally wrong there. The regexp support in mIRC is taken from PCRE, not from Perl. The php function which was mentioned is based on PCRE. Therefore, it should be 100% possible for this to be added in mIRC. And anyway, the fact that it is not internally supported by PCRE doesn't mean anything either. The code that is needed to handle this needs to be in mIRC, not in PCRE. Just like how mIRC can use a regexp in /filter, yet PCRE does not have a filter command.
Posted By: kinnu Re: Regex Tokenizing - 04/08/03 07:48 AM
Quote:
if perl doesnt support that then regex on mIRC never will

Perl does support it

But really, who cares what Perl supports? Perl doesn't have a built-in function for searching an entire hash table with a regex, yet Mirc does ($hfind(...)). Perl is not Mirc, you can have stuff in Perl that you dont have in Mirc and vice versa.
© mIRC Discussion Forums