mIRC Home    About    Download    Register    News    Help

Print Thread
#165484 26/11/06 11:21 PM
Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
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.


Those who fail history are doomed to repeat it
#165485 26/11/06 11:28 PM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
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


$maybe
#165486 26/11/06 11:30 PM
Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
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


Those who fail history are doomed to repeat it
#165487 26/11/06 11:44 PM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
$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)))
}


$maybe
#165488 27/11/06 03:57 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
#165489 27/11/06 10:07 AM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166


Kind Regards, blink

Link Copied to Clipboard