[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
From: |
Joost Kremers |
Subject: |
Re: Use regex in ~/.emacs.d/init.el to match no_proxy. |
Date: |
Sat, 10 Apr 2021 16:05:36 +0200 |
User-agent: |
mu4e 1.5.11; emacs 27.2 |
On Sat, Apr 10 2021, Hongyi Zhao wrote:
> On Thu, Apr 8, 2021 at 2:29 PM Joost Kremers <joostkremers@fastmail.fm> wrote:
> Really, it does the trick:
>
> ~ $ (regexp-opt '("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8"
> "172.16.0.0/12" "192.168.0.0/16"))
> \(?:\*\.cn\|1\(?:0\.0\.0\.0/8\|27\.0\.0\.0/8\|72\.16\.0\.0/12\|92\.168\.0\.0/16\)\|localhost\)
>
>> For Lisp interaction, I'd recommend `M-x ielm`, though.
>
> This also works like a charm:
>
> ELISP> (regexp-opt '("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8"
> "172.16.0.0/12" "192.168.0.0/16"))
> "\\(?:\\*\\.cn\\|1\\(?:0\\.0\\.0\\.0/8\\|27\\.0\\.0\\.0/8\\|72\\.16\\.0\\.0/12\\|92\\.168\\.0\\.0/16\\)\\|localhost\\)"
>
> But why the 2nd method gives the double '\\' escaped sequence for some
> metacharacters while the the 1st method doesn't?
They are different representations of the same thing. In IELM, the return value
is a string, as indicated by the double quotes surrounding the regexp. This is
what you would use in your init file (or in a Lisp program). Eshell prints the
string, i.e., shows you the string in a form that's meant for humans to look at.
--
Joost Kremers
Life has its moments
- Use regex in ~/.emacs.d/init.el to match no_proxy., Hongyi Zhao, 2021/04/06
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Leo Butler, 2021/04/06
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Hongyi Zhao, 2021/04/06
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Gregory Heytings, 2021/04/06
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Hongyi Zhao, 2021/04/06
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., tomas, 2021/04/07
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Hongyi Zhao, 2021/04/07
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Joost Kremers, 2021/04/08
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Hongyi Zhao, 2021/04/10
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy.,
Joost Kremers <=
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Hongyi Zhao, 2021/04/10
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Joost Kremers, 2021/04/11
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Tim Landscheidt, 2021/04/11
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Hongyi Zhao, 2021/04/11
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., tomas, 2021/04/11
- RE: [External] : Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Drew Adams, 2021/04/11
- Re: [External] : Re: Use regex in ~/.emacs.d/init.el to match no_proxy., tomas, 2021/04/12
- Re: Use regex in ~/.emacs.d/init.el to match no_proxy., Robert Thorpe, 2021/04/08