Reputation: 3886
There is a buffer with the following contents.
foo
bar baz bat
more text
Lorem Ipsum fido
The goal is to turn this listing into a HTML table with the following block wrapping each line of the buffer.
<tr>
<td style="text-align: center;">
??Text Here??
</td>
<td style="text-align: center;">
8</td>
<td style="text-align: center;">
 </td>
</tr>
With ??Text Here
replaced with a line from the buffer.
Thoughts?
Upvotes: 4
Views: 73
Reputation: 5198
If the lines are not too long the following works (note the \&
-tick that expands to the full match as it is described in the help of query-replace-regexp
):
(query-replace-regexp "^.*$" "<tr>
<td style=\"text-align: center;\">
\\&
</td>
<td style=\"text-align: center;\">
8</td>
<td style=\"text-align: center;\">
 </td>
</tr>")
Alternatively you can also:
query-replace-regexp
^.*$
into the minibuffer and press enter<tr>
<td style="text-align: center;">
\&
</td>
<td style="text-align: center;">
8</td>
<td style="text-align: center;">
 </td>
</tr>
and press enter and ! to replace all matches.
Upvotes: 2