Using sed:
sed -E '/KEYWORD/{ :lower s/("[^"]*)[a-z]([^"]*")/\1_\2/; t lower; :upper s/("[^"]*)[A-Z]([^"]*")/\1-\2/; t upper; :digit s/("[^"]*)[0-9]([^"]*")/\1*\2/; t digit; }; y/[*_-]/[0xX]/' infile this will run the set of codes in block /KEYWORD/{...} only when a line matched with a string KEYWORD.
("[^"]*)[a-z]([^"]*")it's match to"and anything after that until first lower-case character found which flowed by anything until another quote matched.("[^"]*)[A-Z]([^"]*")it's match to"and anything after that until first upper-case character found which flowed by anything until another quote matched.("[^"]*)[0-9]([^"]*")it's match to"and anything after that until first digit character found which flowed by anything until another quote matched.
every part will loop over again and again until all those characters were converted lower-case to _, upper-case to - and digits to * (note: chose different characters if these may occurred in your file; the reason is we didn't replace directly with x or X or 0 because it will cause infinite loop for sed since of using sed's loops to replace every lower/upper/digit characters);
after all done, those characters [*_-] will translate to [0Xx];
add -i option to above command to update the changes in your input file like sed -i -E ... .