From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: Utilizing Regexp (or something else) to replace an arbitrary string length of the same character with the same string length of another character. Date: Wed, 26 Nov 2008 09:25:56 -0800 (PST) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1227740575 3348 80.91.229.12 (26 Nov 2008 23:02:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Nov 2008 23:02:55 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 27 00:03:58 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L5TQJ-0004eE-3w for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Nov 2008 00:03:55 +0100 Original-Received: from localhost ([127.0.0.1]:50811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L5TP9-000617-NH for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Nov 2008 18:02:43 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!r15g2000prh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 55 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1227720356 13437 127.0.0.1 (26 Nov 2008 17:25:56 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 26 Nov 2008 17:25:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r15g2000prh.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.26.2 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:164811 X-Mailman-Approved-At: Wed, 26 Nov 2008 18:01:35 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:60145 Archived-At: On Nov 26, 6:41 am, "Tim Visher" wrote: > Hello Everyone, > > I have a bunch of arbitrarily long strings of '=3D' characters and I > would like to replace them one for one with '-' characters. I know I > could do this with a simple find and replace using isearch, but that > would require me going through them one at a time. I'm wondering if > there's a way to do this with a regex such as: > > r/(=3D+)/-{length of n} > > Obviously that's a major bastardization of syntax and doesn't really > exist in any language, but I figure this should be able to be done in > Emacs somehow. if your question is about interactive use, then you can use query-replace query-replace-regexp after you type the find string and replace string, you can just type =E2=80=9C!=E2=80=9D to replace them all in one shot in the current buffer. If you don't want it to promp you on the first finding, you can call replace-string instead. If your question is about doing the replacement on whole directory of files, you can mark the files in dired and then invoke dired-do-query- replace-regexp. See: =E2=80=A2 Find and Replace with Emacs http://xahlee.org/emacs/emacs_find_replace.html =E2=80=A2 Interactively Find and Replace String Patterns on Multiple Files http://xahlee.org/emacs/find_replace_inter.html If your question is about writing a lisp program so that you can press a button to do all the replacement you want without needing to answer prompt bout find/replace string, on a single file or bunch of files, it's very easy too. See for example: =E2=80=A2 Elisp Lesson: Repeated Find Replace http://xahlee.org/emacs/elisp_repeat_replace.html > In Christ, =E2=80=A2 Has Religion Made Useful Contributions to Civilization? http://xahlee.org/p/religion_Russell.html Xah =E2=88=91 http://xahlee.org/ =E2=98=84