From: tomas@tuxteam.de
To: Thorsten Bonow <thorsten.bonow@withouthat.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: regexp question
Date: Fri, 7 Jan 2011 11:05:55 +0100 [thread overview]
Message-ID: <20110107100555.GA16425@tomas> (raw)
In-Reply-To: <87d3oaf1q4.fsf@withouthat.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, Jan 06, 2011 at 05:14:59PM +0100, Thorsten Bonow wrote:
>
> Hi,
>
> I wrote the following defun:
>
> (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."
>
> (interactive)
> (query-replace-regexp
> "\\([^\\\\]\\b\\w*\\)f\\(f\\|i\\|l\\|fi\\|fl\\)\\(\\w*\\b\\)"
> "\\1f\"|\\2\\3)"))
>
> 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ás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFNJuWDBcgs9XrR2kYRAiFgAJ4+PG0PZZEV3Umom98OfiiH3bWvMgCcDvQ9
BEeovKmIIWdO8XdmHgtZ7W4=
=RFxZ
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2011-01-07 10:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-06 16:14 regexp question Thorsten Bonow
2011-01-07 10:05 ` tomas [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-09-26 11:18 AW: replace a textblock in multiple files C.Strobl
2006-09-26 12:09 ` regexp question C.Strobl
2006-09-26 17:16 ` Peter Dyballa
2006-09-29 22:03 ` Dieter Wilhelm
2006-09-30 8:53 ` Peter Dyballa
[not found] ` <mailman.7422.1159272599.9609.help-gnu-emacs@gnu.org>
2006-09-27 7:58 ` Florian Kaufmann
[not found] <20040924194238.40080.qmail@web51606.mail.yahoo.com>
2004-09-28 18:21 ` RegExp question JayBingham
2004-09-23 20:23 JayBingham
2004-09-24 19:43 ` Ryan Bowman
[not found] <mailman.3776.1095958718.1998.help-gnu-emacs@gnu.org>
2004-09-23 18:09 ` Stefan Monnier
2004-09-23 16:41 Ryan Bowman
2004-09-23 18:05 ` Greg Hill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110107100555.GA16425@tomas \
--to=tomas@tuxteam.de \
--cc=help-gnu-emacs@gnu.org \
--cc=thorsten.bonow@withouthat.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).