Unescaped forward slash in regex filters?

I’m quite a beginner in regular expressions and so I’m trying to make sense of the exclusion examples provided at Include Exclude Patterns · gilbertchen/duplicacy Wiki · GitHub

One thing I don’t understand is why many of them include a forward slash without it being preceded by a backslash (to escape it) while I thought that a literal forward slash always needs to be escaped (https://regexr.com/ seems to suggest the same).

After some research, I learned from https://stackoverflow.com/questions/43072648/ that there are different regex flavours, depending on which programming language is used. Does that mean that duplicacy works without escaped forward slash? If so, I assume it will still accept \/ as a forward slash?

Another thing I’m trying to figure out is why all examples end with a $. Is this necessary?

When you use regex in Perl, you need to escape the forward slash / because it is used as the match operator in Perl. In most other programing languages, regexes are stored in string literals in which the forward slash has not special meaning and doesn’t need to be escaped.

If the regexes are provided as user input, there is usually no need to escape them just like in most programing languages.

1 Like