2012-10-03 Search and Replace

I was looking at tabular data on a wiki page:

|[[...]]     |   1 |          6563|     3796|   |[[...]] | — |
|[[...]]     | 1/3 |          2315|     1259|   |[[...]] | — |
|[[...]]     | 1/3 |           159|      607|   |[[...]] | — |
|[[...]]     | 1/3 |           159|      597|   |[[...]] | — |

I wanted to add 56 to some of the values in the third column.

Emacs to the rescue: `M-C-%` to run `query-replace-regexp` and search for `^\(|[^|]*|[^|]*|[^|0-9]*\)\([0-9]+\)` and replace it with `\1\,(+ (string-to-number \2) 56))` – I was surprised at how easy it was once I had remembered to use `\,` in the replacement pattern.

EmacsWiki:PierreGaston

​#Emacs