I have a bunch of C integer array initialisation code, e.g.
int a[] = {11,22,33,44};
that I would like to change to strings, e.g.
char *a[] = {"11","22","33","44"};
Is there a reg exp I can use to do this? e.g.
M-x replace-regexp RET
Replace regexp: [0-9] RET
Replace regexp with: "[0-9]" RET
You can do the following:
[0-9]+matches one or more consecutive digits. The escaped parentheses,\(and\), make the contents a group. The\1in the replacement string is replaced with whatever was matched between the first set of escaped parentheses in the query.Thanks to choroba for the reminder in the comments that you can usually use
C-M-%forquery-replace-regexp.