all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* emacs regex to transform text of field1\nfield2\n into field1\tfield2\n etc
@ 2019-02-16 11:23 Angus Comber
  2019-02-16 11:51 ` Angus Comber
  0 siblings, 1 reply; 3+ messages in thread
From: Angus Comber @ 2019-02-16 11:23 UTC (permalink / raw)
  To: Emacs Help

I have a text file of modem country codes like this:

T.35 Code
Country
00
Japan
07
Argentina
09
Australia
0A
Austria


But I want to transform the buffer to look like this:
T.35 Code Country
00              Japan
07              Argentina
09              Australia
0A              Austria

What regex would do that?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: emacs regex to transform text of field1\nfield2\n into field1\tfield2\n etc
  2019-02-16 11:23 emacs regex to transform text of field1\nfield2\n into field1\tfield2\n etc Angus Comber
@ 2019-02-16 11:51 ` Angus Comber
  2019-02-16 16:16   ` Eric Abrahamsen
  0 siblings, 1 reply; 3+ messages in thread
From: Angus Comber @ 2019-02-16 11:51 UTC (permalink / raw)
  To: Emacs Help

I worked it out.

m-%

^\(.*\) Ctrl-Q newline \(.*\)

with

\1 <tab> \2

On Sat, 16 Feb 2019 at 11:23, Angus Comber <anguscomber@gmail.com> wrote:

> I have a text file of modem country codes like this:
>
> T.35 Code
> Country
> 00
> Japan
> 07
> Argentina
> 09
> Australia
> 0A
> Austria
>
>
> But I want to transform the buffer to look like this:
> T.35 Code Country
> 00              Japan
> 07              Argentina
> 09              Australia
> 0A              Austria
>
> What regex would do that?
>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: emacs regex to transform text of field1\nfield2\n into field1\tfield2\n etc
  2019-02-16 11:51 ` Angus Comber
@ 2019-02-16 16:16   ` Eric Abrahamsen
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Abrahamsen @ 2019-02-16 16:16 UTC (permalink / raw)
  To: help-gnu-emacs

Angus Comber <anguscomber@gmail.com> writes:

> I worked it out.
>
> m-%
>
> ^\(.*\) Ctrl-Q newline \(.*\)
>
> with
>
> \1 <tab> \2
>
> On Sat, 16 Feb 2019 at 11:23, Angus Comber <anguscomber@gmail.com> wrote:
>
>> I have a text file of modem country codes like this:
>>
>> T.35 Code
>> Country
>> 00
>> Japan
>> 07
>> Argentina
>> 09
>> Australia
>> 0A
>> Austria
>>
>>
>> But I want to transform the buffer to look like this:
>> T.35 Code Country
>> 00              Japan
>> 07              Argentina
>> 09              Australia
>> 0A              Austria
>>
>> What regex would do that?

FWIW, I usually do these things with keyboard macros. If the source data
is very regular, it can be much faster than finding the right regex. In
this case it would be very easy to record: end-of-line,
delete-next-character, insert-tab, next-line.

Eric




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-16 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-16 11:23 emacs regex to transform text of field1\nfield2\n into field1\tfield2\n etc Angus Comber
2019-02-16 11:51 ` Angus Comber
2019-02-16 16:16   ` Eric Abrahamsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.