I was interested in converting octal chars to hex chars in a source file.
I wanted to query search and replace on the following text:
'\0' -> "\\0", // Null
'\7' -> "\\a", // Bell (^G)
'\b' -> "\\b", // Backspace (^H)
'\13' -> "\\v", // Vertical tab (^K)
'\33' -> "\\e", // Escape (^[)
Here was the regular expression search and replace
C-M-%
'\\\([0-9]+\)'
RET
'\,(format "\\0x%04X" (string-to-number \1 8))'
RET
The result is:
'\0x0000' -> "\\0", // Null
'\0x0007' -> "\\a", // Bell (^G)
'\b' -> "\\b", // Backspace (^H)
'\0x000B' -> "\\v", // Vertical tab (^K)
'\0x001B' -> "\\e", // Escape (^[)