[squid-users] regexp on refresh_pattern

Amos Jeffries squid3 at treenet.co.nz
Thu Apr 6 14:22:03 UTC 2017


On 5/04/2017 1:45 a.m., Heiler Bemerguy wrote:
> 
>>> Dudes, are these escaped characters right, for refresh_pattern syntax?
>>>
>>> *refresh_pattern -i personal\.avira\-update.com.*\.(gz|idx|lz)$ 40320
>>> 80% 120960 override-expire ignore-private ignore-no-store store-stale
>>> ignore-reload ignore-must-revalidate*
>>>
>> To which the only possible answer is:
>>    Are you referring to the escaped characters or the non-escaped
>> characters?
>>
> 
> Escaped. Is it really necessary to escape dots and hyphens?


That depends on what you want it to match. Dot (.) and hyphen (-) have
special meanings in regex, so if you want to match those exact
characters in the input, then yes you need to \-escape them.

> And, will
> the $ really makes it verify from the right to the left ?
> 

Huh? never heard "verify" in regards to regex. If you mean scan, that is
something your OS regex library implementation may or may not do.

Dollar ($) is the end-anchor, the pattern is only a match if the ending
of the URL is at that position in relation to the rest of the pattern
pieces.


FYI: none of this has anything particular to do with Squid. It is basic
regular expressions. You should lookup a beginners guide to regular
expressions for these answers and many other useful things about regex.

Amos



More information about the squid-users mailing list