replacing x with y OR z ?

March 9, 2010 at 14:36:44
Specs: Windows XP
Hi

I have a little problem. I want to build a command line batch text
encoder/decoder. I have the rest of the program done, but i have
a problem. So what i want is:

replace every "a" letter with "this" OR "that"
replace every "b" letter with "this" OR "that"
etc.

(in a variable, which is a text, waiting to be encoded)

I know how to replace letters in a string, but only with a specified value. But i want to make it to replace every
letter "x" with one letter, which can be "A" "B" "C" or "D", and i want to make the batch file to choose randomly which one to put in the place of the original letter.


See More: replacing x with y OR z ?

Report •


#1
March 10, 2010 at 15:44:17
set letters=abcd
set len=4
set /a xx="%random%%%len"
set lettr=!letters:~%xx%,1!
set word=!word:x=%lettr%!

Report •

#2
March 11, 2010 at 07:13:36
thanks

Report •
Related Solutions


Ask Question