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

[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: Gregory Heytings
Subject: Re: Use regex in ~/.emacs.d/init.el to match no_proxy.
Date: Tue, 06 Apr 2021 16:56:52 +0000


As you can see, the "no_proxy" string is rather cumbersome, and I want to express the following, but I still don't know what to do:

"*.cn,localhost,10.0.0.0/8,127.0.0.0/8,172.16.0.0/12,192.168.0.0/16"

Any hints will be highly appreciated.

C-h i f regexp-opt RET


That should have been C-h S regexp-opt RET.

(regexp-opt '("*.cn" "localhost" "10.0.0.0/8" "127.0.0.0/8" "172.16.0.0/12" 
"192.168.0.0/16"))

will return

"\\(?:\\*\\.cn\\|1\\(?:0\\.0\\.0\\.0/8\\|27\\.0\\.0\\.0/8\\|72\\.16\\.0\\.0/12\\|92\\.168\\.0\\.0/16\\)\\|localhost\\)"

but I suspect this is not what you want, because:

1. you probably want to add a ^ at the beginning and a $ at the end of the regexp

2. you probably want to replace \\* by .+

3. regexp-opt does not understand that the IP address notation is a kind of wildcard, IOW, you probably do not want to match "10.0.0.0/8" but instead "10.0.0.1", "10.0.0.2", ..., "10.255.255.254", "10.255.255.255".



reply via email to

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