From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: emacs regex to transform text of field1\nfield2\n into field1\tfield2\n etc Date: Sat, 16 Feb 2019 08:16:46 -0800 Message-ID: <87h8d3wvwx.fsf@ericabrahamsen.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="221033"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 16 17:17:20 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gv2eW-000vHC-6t for geh-help-gnu-emacs@m.gmane.org; Sat, 16 Feb 2019 17:17:20 +0100 Original-Received: from localhost ([127.0.0.1]:57688 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gv2eQ-0006am-0S for geh-help-gnu-emacs@m.gmane.org; Sat, 16 Feb 2019 11:17:14 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gv2eB-0006aR-Az for help-gnu-emacs@gnu.org; Sat, 16 Feb 2019 11:16:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gv2e9-0001gU-Cr for help-gnu-emacs@gnu.org; Sat, 16 Feb 2019 11:16:59 -0500 Original-Received: from [195.159.176.226] (port=39828 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gv2e8-0001fK-Ea for help-gnu-emacs@gnu.org; Sat, 16 Feb 2019 11:16:57 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1gv2e4-000urI-Ar for help-gnu-emacs@gnu.org; Sat, 16 Feb 2019 17:16:52 +0100 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:Zi8O6PgxG+OwLoAbPj0GMZGmEX4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:119433 Archived-At: Angus Comber writes: > I worked it out. > > m-% > > ^\(.*\) Ctrl-Q newline \(.*\) > > with > > \1 \2 > > On Sat, 16 Feb 2019 at 11:23, Angus Comber 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