mIRC Homepage
Posted By: landonsandor MINOR $replace idea - 26/11/06 11:21 PM
Ok, something that would be nice would be if we could use regex in $replace like this:

$replace(text,[a-z],--)

So if I wanted to replace any letter that shows up, with (for example) --, I could use a regex filter or it. So if I wanted to do a hangman type of script and replace all letters with a <space>_<space>, I wouldnt need to script it. As I said, a MINOR addition and it can be scripted now I know.
Posted By: Mpdreamz Re: MINOR $replace idea - 26/11/06 11:28 PM
Thats what $regsubex is for smile
What $replace would offer is multiple substitutions in one alias as supposed to nested $regsubex calls which might be nice.
Extending $regsubex to $regsubex(string,re1,replacement1[,re2,replacement2,....])
would make more sence though smile
Posted By: landonsandor Re: MINOR $replace idea - 26/11/06 11:30 PM
I've never used $regsubex - obviously Im doing a game with hangman. It's not a mirc hangman game, but I use mirc and one or two other programs to make coding a soupload (yeah, thats self censored lol) easier smile
Posted By: Mpdreamz Re: MINOR $replace idea - 26/11/06 11:44 PM
$regsubex is a charm smile
sucky example:
Code:
alias hangman { 
  set %word carbon-oxide
  echo -a $regsubex(%word,/([a-z])/g,$+($chr(32),_,$chr(32)))
  ;simulate a guess for C
  set %word $replace(%word,c,C)
  echo -a $regsubex(%word,/([a-z])/g,$+($chr(32),_,$chr(32)))
  ;simulate a guess for O
  set %word $replace(%word,o,O)
  echo -a $regsubex(%word,/([a-z])/g,$+($chr(32),_,$chr(32)))
}
Posted By: Riamus2 Re: MINOR $replace idea - 27/11/06 03:57 AM
You could always use $len to find the length of the words and then output $str(_,$len(%word1)) or something like that. Though I'm sure the regex method posted works quite well also.
Posted By: b1ink Re: MINOR $replace idea - 27/11/06 10:07 AM
$rreplace by myggan
© mIRC Discussion Forums