From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.emacs.help Subject: Re: regexp question Date: Fri, 7 Jan 2011 11:05:55 +0100 Message-ID: <20110107100555.GA16425@tomas> References: <87d3oaf1q4.fsf@withouthat.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1294394012 28061 80.91.229.12 (7 Jan 2011 09:53:32 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 7 Jan 2011 09:53:32 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Thorsten Bonow Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jan 07 10:53:27 2011 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.69) (envelope-from ) id 1Pb90g-0008Fn-RX for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Jan 2011 10:53:27 +0100 Original-Received: from localhost ([127.0.0.1]:51018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pb90g-0006Qb-BZ for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Jan 2011 04:53:26 -0500 Original-Received: from [140.186.70.92] (port=39582 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pb906-0006QT-HF for help-gnu-emacs@gnu.org; Fri, 07 Jan 2011 04:52:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pb905-0002MS-B2 for help-gnu-emacs@gnu.org; Fri, 07 Jan 2011 04:52:50 -0500 Original-Received: from alextrapp1.equinoxe.de ([217.22.192.104]:49508 helo=www.elogos.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pb905-0002Ly-3x for help-gnu-emacs@gnu.org; Fri, 07 Jan 2011 04:52:49 -0500 Original-Received: by www.elogos.de (Postfix, from userid 1000) id 283CB9004B; Fri, 7 Jan 2011 11:05:55 +0100 (CET) Content-Disposition: inline In-Reply-To: <87d3oaf1q4.fsf@withouthat.org> User-Agent: Mutt/1.5.15+20070412 (2007-04-11) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:78286 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thu, Jan 06, 2011 at 05:14:59PM +0100, Thorsten Bonow wrote: >=20 > Hi, >=20 > I wrote the following defun: >=20 > (defun yyy-rmligs() > "Function to call `query-replace-regexp' and search > for words, ignoring LaTeX commands starting with a backslash, > which contain ligatures 'ff', 'fi', 'fl', 'ffi' and 'ffl' and > queries about replacing them with their LaTeX non-ligature > variant. E.g. 'shelfful' could be replaced by 'shelf\"|ful', > while '\\flushright' is ignored." >=20 > (interactive) > (query-replace-regexp > "\\([^\\\\]\\b\\w*\\)f\\(f\\|i\\|l\\|fi\\|fl\\)\\(\\w*\\b\\)" > "\\1f\"|\\2\\3)")) >=20 > It works, unless there is more then one ligature in the word. Hm. Tough one. You might substitute the \w* by its non-greedy \w*?. But then I guess you would just hit the *first* ligature and pass the second. Possibly you'd have to modify the "head", to allow it to begin with \w right away when not at word boundaries (i.e. in the middle of the word). Or you bite the bullet and code the loop yourself, so you have more control of the restart points. Regards - -- tom=C3=A1s -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFNJuWDBcgs9XrR2kYRAiFgAJ4+PG0PZZEV3Umom98OfiiH3bWvMgCcDvQ9 BEeovKmIIWdO8XdmHgtZ7W4=3D =3DRFxZ -----END PGP SIGNATURE-----