Page 1 of 1
Breaking Search
Posted: 12 Nov 2013 03:04
by Enternal
This happens a few times in the past and always bothered me but I think I should report it.
There are terms that whenever I do a search, I get an "invalid syntax error"
Sample terms:
Code: Select all
[Titan-Mons]
[Tsuki-Hatsuyuki]
[Sad-Day-Man]
[Sad-Day]
[Would-You-Like-Some-Tea]
Not only that, these name search when they do "work" like "[Break-Pony]", you get results that have NOTHING to do with the name. For example doing a search in XYplorer's data folder, I got:
and more unrelated files
Same issue with fresh install. It's a very odd problem and I could not figure out what could trigger it. They all related to the brackets though...
Re: Breaking Search
Posted: 12 Nov 2013 03:33
by armsys
Enternal wrote:This happens a few times in the past and always bothered me but I think I should report it.
Would you like to try it out with regex?
eg \[Titan\-Mons\]
Re: Breaking Search
Posted: 12 Nov 2013 03:49
by TheQwerty
I'm guessing here because my Windows box hosed itself this afternoon...
XY is treating your queries as character lists, similar to those used by regular expressions, so '[Titan-Mons]' is matching a single character which is t, i, t, a, n through m, o, n, or s.
Now the reason that '[Break-Pony]' doesn't give an error like those other examples is because XY only supports ranges that are in the "correct order", I presume. Since P is after k this range is expanded properly, but in the previous example n is not before M so the range causes an error. I guess a single character range, d-D, might also cause an error, or it might be because of the capitalization since ASCII D is < ASCII d. (Though this might depend on whether you're searching with match case enabled.)
Try your searches again but escape the opening bracket by doubling it (ie. '[[Titan-Mons]') and I think it should work as you expect.
HTH
Re: Breaking Search
Posted: 12 Nov 2013 04:07
by Enternal
armsys wrote:Enternal wrote:This happens a few times in the past and always bothered me but I think I should report it.
Would you like to try it out with regex?
eg \[Titan\-Mons\]
This works perfectly! However... (more to it down below)
TheQwerty wrote:I'm guessing here because my Windows box hosed itself this afternoon...
XY is treating your queries as character lists, similar to those used by regular expressions, so '[Titan-Mons]' is matching a single character which is t, i, t, a, n through m, o, n, or s.
Now the reason that '[Break-Pony]' doesn't give an error like those other examples is because XY only supports ranges that are in the "correct order", I presume. Since P is after k this range is expanded properly, but in the previous example n is not before M so the range causes an error. I guess a single character range, d-D, might also cause an error, or it might be because of the capitalization since ASCII D is < ASCII d. (Though this might depend on whether you're searching with match case enabled.)
Try your searches again but escape the opening bracket by doubling it (ie. '[[Titan-Mons]') and I think it should work as you expect.
HTH
I tried it with '[[Titan-Mons]' and it still gave me an error. What's odd is I have my search set to Standard and not RegEx or Boolean so it really is odd how armsys's examples works perfectly with search settings set to Standard. Now, if I enclose my search in double quotes like -> "[Titan-Mons]"-> I would expect it to work since I'm explicitly searching for that but still the same problem. Actually that's how I first encountered the problem (with quotes).
EDIT: FOUND IT!! Thanks to you two, so I found the cause. It seems that the Search mode is not really followed or something. Whether I set the mode to Standard, Boolean, or RegEx, a regex search using "x[0-9A-Z]" will get the same exact results in all 3 modes!
Re: Breaking Search
Posted: 12 Nov 2013 04:25
by TheQwerty
Enternal wrote:I tried it with '[[Titan-Mons]' and it still gave me an error. What's odd is I have my search set to Standard and not RegEx or Boolean so it really is odd how armsys's examples works perfectly with search settings set to Standard. Now, if I enclose my search in double quotes like -> "[Titan-Mons]"-> I would expect it to work since I'm explicitly searching for that but still the same problem. Actually that's how I first encountered the problem (with quotes).
EDIT: FOUND IT!! Thanks to you two, so I found the cause. It seems that the Search mode is not really followed or something. Whether I set the mode to Standard, Boolean, or RegEx, a regex search using "x[0-9A-Z]" will get the same exact results in all 3 modes!
Well it's just that the character class is supported by all three modes, so they should be equivalent. More precisely it's that the way to define a character list in standard and boolean modes is exactly how it is done for regex, so of the wildcards XY supports, character lists are the only one that is supported as-is in all three modes. Though how you escape '[' is different than how you do so in a regex.
I thought the escape for '[' was doubling it but perhaps it's putting it in a character class by itself - maybe '[[]Titan-Mons]' is correct?
Re: Breaking Search
Posted: 12 Nov 2013 04:30
by Enternal
Oh I see. Is there no way to do a strict as-is search without using the QNS? And yes, the "[[]Titan-Mons]" does indeed work. So the escape character also accommodate the "]" character at the end? Or should I also add in the brackets for the last one just in case? -> "[[]Titan-Mons[]]"
Aargh, that means my script will need to be changed. Plus I'm not great with RegEx and boolean stuff so guess need to work on that now. The reason is [Titan-Mons] is only part of the file name. The entire file name gets pretty long like:
[Titan-Mons]_Episode_3-Return_of_the_Tea_Cup_[DVD][848x480][FFEA18F0]
so as you can see, it gets pretty "hectic" when I want to do multiple file searches using ";" with those types of names.
Re: Breaking Search
Posted: 12 Nov 2013 04:41
by TheQwerty
Enternal wrote:Oh I see. Is there no way to do a strict as-is search without using the QNS?
I'm not sure if XY continues to support wildcards when Whole Words is enabled - but short of that I don't know if there's another way to force a literal search without doing the escaping yourself.
Enternal wrote: And yes, the "[[]Titan-Mons]" does indeed work. So the escape character also accommodate the "]" character at the end? Or should I also add in the brackets for the last one just in case? -> "[[]Titan-Mons[]]"
The ']' doesn't need escaped because XY doesn't view the character list as opened/started when the '[' is escaped properly.
Enternal wrote:Aargh, that means my script will need to be changed. Plus I'm not great with RegEx and boolean stuff so guess need to work on that now. The reason is [Titan-Mons] is only part of the file name. The entire file name gets pretty long like:
[Titan-Mons]_Episode_3-Return_of_the_Tea_Cup_[DVD][848x480][FFEA18F0]
so as you can see, it gets pretty "hectic" when I want to do multiple file searches using ";" with those types of names.
You could write a "subscript" which escapes the search queries before doing the search vs. you having to enter the escaped query. Either way if you post some example queries and expected results or items to search, I bet someone here can help.
Re: Breaking Search
Posted: 12 Nov 2013 04:52
by Enternal
TheQwerty wrote:Enternal wrote:Oh I see. Is there no way to do a strict as-is search without using the QNS?
I'm not sure if XY continues to support wildcards when Whole Words is enabled - but short of that I don't know if there's another way to force a literal search without doing the escaping yourself.
Ah I see. I hope Don have some input on this to see if there's any way to do a literal search only.
TheQwerty wrote:Enternal wrote: And yes, the "[[]Titan-Mons]" does indeed work. So the escape character also accommodate the "]" character at the end? Or should I also add in the brackets for the last one just in case? -> "[[]Titan-Mons[]]"
The ']' doesn't need escaped because XY doesn't view the character list as opened/started when the '[' is escaped properly.
Ah! That makes sense. Since "[" is a RegEx indicator so if we escape it, no need to worry about everything until another opening bracket comes up right?
TheQwerty wrote:Enternal wrote:Aargh, that means my script will need to be changed. Plus I'm not great with RegEx and boolean stuff so guess need to work on that now. The reason is [Titan-Mons] is only part of the file name. The entire file name gets pretty long like:
[Titan-Mons]_Episode_3-Return_of_the_Tea_Cup_[DVD][848x480][FFEA18F0]
so as you can see, it gets pretty "hectic" when I want to do multiple file searches using ";" with those types of names.
You could write a "subscript" which escapes the search queries before doing the search vs. you having to enter the escaped query. Either way if you post some example queries and expected results or items to search, I bet someone here can help.
Thanks! Well, I always do a lot of trial and error anyway but if I do run into a roadblock, I will definitely ask for help. In the mean time, I'm doing a search of over 50 files separated with a ";" and I currently simply use:
Code: Select all
$SearchTerm = Replace($SearchTerm, "[", "[[]");
and it seems to work fine so far! Plus to be honest, this actually makes my TorrentMatchup (in the Scripts forum) perform much better than before! No longer need to mess around with the fuzzy setting as much now. Thanks!
Re: Breaking Search
Posted: 12 Nov 2013 09:58
by admin
The recommended way is to escape the opening bracket with \:
This works as well:
"Whole words" will also not see [...] as a group of characters, but it will not match "[Titan-Mons]a.txt".