mIRC Homepage
Posted By: Sabby $replace and etc... - 13/02/03 11:27 PM
I was wondering how could i replace everything in text exept the volews...

Example:

If i entered: Hello everyone
it would return: *e**o e*e**o*ne

And also is there an easier more suffient way of replacing all text and chrs with * in that... i cant just do $str(*,$len($1-)) because then it would be one line..


Thanks
Posted By: Nimue Re: $replace and etc... - 13/02/03 11:43 PM
//tokenize 32 hello everyone | .!echo -q $regsub($1-,/[^aeiou\x20]/g,*,%a) | echo -a %a


edit--
Whhops, no var %a declared.. *slaps herself* blush

//tokenize 32 hello everyone | var %a | .!echo -q $regsub($1-,/[^aeiou\x20]/g,*,%a) | echo -a %a
Posted By: Sabby Re: $replace and etc... - 14/02/03 12:28 AM
would you mind explaining:
\x20]/g
and /[ at the begging?

i know ^ means begging of text..
Posted By: Nimue Re: $replace and etc... - 14/02/03 12:45 AM
the expression is enclosed in / ... /
[<xxx>] is a class to match (in this case, aeiou)
[^<xxx>] is a class to NOT match
"g" means global (not just the first instance)
"\x" + up to two hexadecimal digits to match - \x20 = $chr(32)

For info on $regex, man.txt is very useful smile
Posted By: Sabby Re: $replace and etc... - 14/02/03 01:32 AM
so i could do: $regsub($1-,/[a-zA-Z0-9\x20]/g,*,%a)

will replace everything?
ie: hello everyone = $1-
and it would return ***** ********
Posted By: Nimue Re: $replace and etc... - 14/02/03 01:36 AM
Or: $regsub($1-,/\S/g,*,%a) smile
Posted By: Sabby Re: $replace and etc... - 14/02/03 01:51 AM
wow.. regex is complicated.. i guess ill read through that tutorial

thanks so much Nimue
Posted By: Nimue Re: $replace and etc... - 14/02/03 01:57 AM
It's not all that complicated really, once you know a litle, more becomes clearer. (like most new things) grin
The man.txt file is a great reference, but try a simple tutorial first smile
Posted By: qwerty Re: $replace and etc... - 14/02/03 05:45 AM
You can just use a literal space in the class, instead of \x20, and save 3 chars! smile
Posted By: Nimue Re: $replace and etc... - 15/02/03 07:44 PM
Yeah $true, I know that, also \s, I just find \x format more readable in some cases. (Maybe i'm weird, but I care not) smile
© mIRC Discussion Forums