help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: regexp question


From: tomas
Subject: Re: regexp question
Date: Fri, 7 Jan 2011 11:05:55 +0100
User-agent: Mutt/1.5.15+20070412 (2007-04-11)

-----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-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]