I'm working with TeX-Files which are converted from other formats. One thing that pops up in these are vertical lines in tables like the following:
\cline{1-1}\cline{2-2}...\cline{n-n}
This can be expressed in a compressed fashion as
\cline{1-n}
It is further complicated by the fact that multiple such ranges might appear in the same line, for example 1-5
, 7-11
and 15-17
all might appear on the same line, which prevents me from just looking for the first and last ones and using those.
I attempted to compress these with query-replace-regexp
, where I tried to replace \\cline{\([0-9]+\)-\1}\\cline{\,(+ 1 \#1)-\,(+ 1 \#1)}
with \cline{\1-\,(+ 1 \#1)}
, which did not work. Can this be done, and if yes, how? Also I'd prefer this a an elisp-Macro so that I can easily reuse it.