[squid-users] Regex for URL to include numbers special letters

Amos Jeffries squid3 at treenet.co.nz
Sat May 21 02:39:10 UTC 2022


Your solution may "works", but only partial.

Diving back to your original request:

On 20/05/22 02:25, robert k Wild wrote:
 > hi all,
 >
 > want to make the below into a regex as after the io..., could be any
 > number and letter, the - stays in the same position but to make it
 > simple i just want to make anything a wildcard
 >
 > http://zzz-iobuckets-io50-1lnk65fe5gm7n.s3.amazonaws.com/
 > <http://zzz-iobuckets-io50-1lnk65fe5gm7n.s3.amazonaws.com/>
 >
 > something like this ive done but it doesnt work
 >
 > "^zzz-iobuckets-io.*.s3.amazonaws.com <http://s3.amazonaws.com>$"
 >


Please notice that your regex does **not** match any valid "URL".

It explicitly only matches strings that start without a scheme. This is 
matching only URI. Specifically it matches URI-authority which HTTP only 
sees in CONNECT request-target's.


I think what you actually want is this:

   ^zzz-iobuckets-io[0-9]+-[0-9a-z]+\.s3\.amazonaws\.com:[0-9]$


That will limit the successful matches to amazonaws.com sub-domains. 
Preventing things like "zzz-iobuckets-io.s3.amazonaws.com.example.com"


FYI, The regex language supported by Squid is the original GNU regex. 
The operators are ^, $, +, *, ?, |, \x, [^-], and (). No character 
classes, back references, or repetition groups.


HTH
Amos



More information about the squid-users mailing list