Re: Matching the beginningor end of an address
"Kevin J. McCarthy" <[email protected]> Sun, 29 Mar 2026 20:44:41 +0800
| Newsgroups | gmane.mail.mutt.user |
|---|---|
| Message-ID | <ackeuQHz8cc3iZDV@qinghai> |
--x1uoO4+fNmc8yedR Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 29, 2026 at 02:29:41PM +0200, S=C3=A9bastien Hinderer wrote: >Kevin J. McCarthy (2026/03/29 20:05 +0800): >> On Sun, Mar 29, 2026 at 12:45:13PM +0200, S=C3=A9bastien Hinderer wrote: >> > In my configuration I have hooks like >> > >> > save-hook '~f amazon.fr' '=3Damazon/' >> > >> > As such, I am assuming that a mail sent from any address *ocntaining* >> > amazon.fr, like for instance [email protected], would >> > match. >> > >> > Is there a way to make the regexp more restrictive and to match those >> > messages where amazon.fr appears at the end of the address? >> >> Yes, see the example at http://www.mutt.org/doc/manual/#pattern-hook for= an >> example. It shows send-hook, but this also works for save-hook. > >Oh ye, indeed! But then is it documented somewhere that ^ and $ work? Is >it on purpose that they are not mentionned in the part of the manual >about regular expressions? Yes, at http://www.mutt.org/doc/manual/#regexp see the sentence: The period =E2=80=9C.=E2=80=9D matches any single character. The caret = =E2=80=9C^=E2=80=9D and the dollar sign =E2=80=9C$=E2=80=9D are metacharacters that respectively mat= ch the empty string at the beginning and end of a line. >> Also notice in the example how "." is backslashed, because that matches = any >> character. > >I indeed didn't pay attention so far. I think I was under the wrong >impression that, because the pattern is between single quotes, . is >taken litteraly. From a "shell quoting" point of view, single quotes make everything be=20 un-evaluated. But regular expressions are an additional layer of=20 complexity, evaluated after the string is processed by mutt. >So we agree that, for isntance int he example you show, the quotes are >not at all optional and that, although they are there, the special >characters occurring in regular expresisons between these quotes do need >to be escaped to get back their ordinary meaning? Without the single quotes, it gets trickier, because you have two layers=20 to go through. I definitely recommend you use single quotes or you'll=20 have to double the backslashes. See the second example line at=20 http://www.mutt.org/doc/manual/#save-hook for what that looks like. --=20 Kevin J. McCarthy GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA --x1uoO4+fNmc8yedR Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEiXWpszqjeRA4XFMIre92hIAxa9oFAmnJHrkACgkQre92hIAx a9qdcA//br8qxbVduJG4cSDZE8uCNfhgd9/9UylpBihbsQrHF08R2zlSHe8T6Zw2 MkgSjO1pq8WU7saYfk6tOFDiv0JJfmZ/9hK8uuXRkMFEggVnJajLL0ZyUSewa70+ zEXQssrs6pzVse8G/VrkFy8cdQ07s8ppqicscCEHx24sawyhDhQicfQFpuDY2ViE 8X+g68nue5OCQcJlgcbwF0byyysrL6oZJ/eB7DFSJLu9qd0oQZyPLWZSXtdTAaXZ /Rju3LEOnkgp3pzLlyDS1a481FZH6RZ+3SbP3B0q4b858J5z3B92z5ChQOA3VRtl r1752LyFmqE4jhhMWg0LpkvRG/Rq89GKRSzx0l9DUgpveRmnAq8PuMCfDITSfbCX 1k+oRP0mIj4fMz40m/2YC8Df9cYsDuCBq8HA3v+M+u3YJUWZ7mX3Vqc6CFvuQvTR u9sLTWeoAG6pTSBC8yR1aFCW2NpYE7VLkGlhrRa4h3id31Z8x2Ae3hRu7rD+noVY BTwj2660xS2iAXDOg4ucoDE9EZmq31ufU05xkMUaKa9dHv6Bfj7jOuULJscLbj7t Kb1kgP7G39EmWGomKlDdUyb0cYZBvq0opwvljSzOpuAKg4N4mBiUfZIyDBk7ILxk Y540jwHUGY60rN8fbSYVQXW/dj8VF1NtYCFggmpb6/W/zDSPDuA= =ljUV -----END PGP SIGNATURE----- --x1uoO4+fNmc8yedR--