Page 1 of 1
Incorrect regular expressions work
Posted: Wed Dec 27, 2017 12:10 am
by redisko
Incorrect regular expressions work. For example:
It does not find files with extensions mp4, avi, mkv, vob, mpg. The result completely defies any logic
Generally speaking, this expression should be equivalent to the following:
Code: Select all
regex:\.mp4$|\.avi$|\.mkv$|\.vob$|\.mpg$
Re: Incorrect regular expressions work
Posted: Wed Dec 27, 2017 1:02 am
by NotNull
redisko wrote:Incorrect regular expressions work. For example:
It does not find files with extensions mp4, avi, mkv, vob, mpg. The result completely defies any logic
Generally speaking, this expression should be equivalent to the following:
Code: Select all
regex:\.mp4$|\.avi$|\.mkv$|\.vob$|\.mpg$
The "|" has a double meaning:
It can be an OR in your regex, but it could also mean: the end of the regex and the start of a next query (for example: path:c:\windows)
So, even your second example will probably not give you the right results. This one should give the right results:
Code: Select all
regex:\.mp4$|regex:\.avi$|regex:\.mkv$|regex:\.vob$|regex:\.mpg$
Or escape the | by enclosing it in double quotes (using your second example):
Code: Select all
regex:\.mp4$"|"\.avi$"|"\.mkv$"|"\.vob$"|"\.mpg$
Your short version would become:
Code: Select all
regex:\.(mp4"|"avi"|"mkv"|"vob"|"mpg)$
BTW: I assume this was just an example. Otherwise you could get the same results wit a simple: