Diary SiteMap RecentChanges About Contact 2012-10 Calendar

Search:

Matching Pages:

2012-10-03 Search and Replace

Last edit

Changed:

< ##(string-to-number \2)##. I guess I should not have finished reading

to

> ##(string-to-number \2)##. I guess I should have finished reading


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.

Update: EmacsWiki:PierreGaston tells me that I could have used \#2 instead of (string-to-number \2). I guess I should have finished reading that paragraph on the Info page. ;)

Tags: RSS

Comments

Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.

Show Google +1