Boolean RegEx

Features wanted...
Mesh
Posts: 956
Joined: 24 Mar 2008 21:22

Re: Boolean RegEx

Post by Mesh »

admin wrote:
Thanks for the examples!

Actually I was thinking of adding just a tiny little thing to the already existing Boolean syntax: Prefix ">" to a Regexp pattern. That way one could freely combine RegExp and normal wildcard patterns in a easy fashion.

I can't say I'm fond of that idea, to be honest. It lacks neatness and clarity - the fact that RegEx statements are not clearly delineated causes parsing complications, as both ">" characters as well as words like "OR", "AND" and "AND NOT" can be part of a valid RegEx.

Rather than adding RegEx to the Boolean syntax, I think it is preferable to add Boolean support to the RegEx. So that anywhere that RegEx is supported in XY, Boolean RegEx is supported as well. It's just a matter of whether or not there are RegEx statements surrounded by delineator characters. To me, this seems much more natural, easier to read, and less likely to cause parsing complications.

Demset
Posts: 50
Joined: 02 Nov 2008 06:22

Re: Boolean RegEx

Post by Demset »

serendipity wrote:
Welcome to the Club!

Thanks for the warm welcome! I've been lurking for a while, but I had to finally chime in when I saw someone propose this. :)

Demset
Posts: 50
Joined: 02 Nov 2008 06:22

Re: Boolean RegEx

Post by Demset »

I think I agree with mesh, I see too many problems with having no clear seperation of statements. Not only are angle brackets and the boolean words things you'd find in normal regexes, but spaces are a normal part of regex statments, too. That just makes it a royal mess, unless each statement is clearly defined. Not only would the customizeable string be better, but another safeguard is that it would only be valid as delineators if there were matching pairs.

Also, something rubs me the wrong way about adding RegEx support to Boolean, rather than the other way around - I know, not very scientific, but I feel it, so I figure I'd mention it.

I like what was suggested earlier - each regex surrounded by customizeable strings, with the boolean logic and grouping outside. And building in the boolean support to every place that takes regex - it just makes more sense. I've tried to think of any better way to do it, but so far, I haven't been able to come up with anything better.

Anyway, that's my 2 cents. <g>

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Boolean RegEx

Post by j_c_hallgren »

Demset wrote:Thanks for the warm welcome! I've been lurking for a while, but I had to finally chime in when I saw someone propose this. :)
:shock: Lurking for a while? And nothing before this prompted a posting? :lol: Anyway, I also extend a welcome to the XY forums and hope you'll continue to contribute!
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

admin
Site Admin
Posts: 66310
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Boolean RegEx

Post by admin »

Concerning the critique of my proposal: I see your points, but all the potential problems you mentioned pertain just as well to Boolean combinations of non-regexp patterns and are solved since long: you escape stuff using \.
So I will just add the little extra I mentioned and we'll see how it works out in real world file searching.

Mesh
Posts: 956
Joined: 24 Mar 2008 21:22

Re: Boolean RegEx

Post by Mesh »

admin wrote:
Concerning the critique of my proposal: I see your points, but all the potential problems you mentioned pertain just as well to Boolean combinations of non-regexp patterns and are solved since long: you escape stuff using \.
So I will just add the little extra I mentioned and we'll see how it works out in real world file searching.

I'm not saying that there aren't always issues - but it seems like this method is going to cause some unnecessary issues and complications. Searching for files like "2008-12-03 OR Surgical supply List.doc", might involve a RegEx such as "\d{4}-\d{1,2}-\d{1,2} OR". It seems to me that it would be a lot less complicated, not to mention easier to read if this RegEx was surrounded by delineators as opposed to what you're proposing.


For example:

Code: Select all


"\d{4}-\d{1,2}-\d{1,2} OR" AND "Pattern 2"


vs.

Code: Select all


\d{4}-\d{1,2}-\d{1,2} OR AND Pattern 2


What you're proposing would now require escaping entire words, which complicates the RegEx unnecessarily, and would make readability a nightmare in certain circumstances.

Plus, it makes RegEx a nightmare in general. You're suggesting that if you want to include the word "AND" in your search pattern, that you type it as "\AND". But in RegEx, "\A" and "\a" have special meanings, so are you using an escaped boolean word, or are you referring to a RegEx "\A" or "\a" followed by an "ND"?


On the other hand, if you clearly seperate the RegEx statements, most of these issues go away. For example, if you defaulted XY to use "**" as the delineator - it's *really* unlikely that this pattern of the double asterisk would be used in RegEx for XY. It might be used for RegEx in general, but because XY is a file manager, and the asterisk is an illegal character for file names, you're pretty safe for the majority of possible cases. And for those exceptions, a person can edit the INI file and change it appropriately.

admin
Site Admin
Posts: 66310
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Boolean RegEx

Post by admin »

I added quoting. And kept the old way to work without quotes (using backslashes to escape critical sequences). Good solution. Thanks for pushing! :D

Demset
Posts: 50
Joined: 02 Nov 2008 06:22

Re: Boolean RegEx

Post by Demset »

I just gave the new version a shot. I'm thrilled that this has been added! And I'm also glad for the quoting support (thanks, Don! thanks, Mesh!).

But I have a problem because the regex support was added to the boolean search, instead of boolean support being added to regex. I will fervently vote for the latter, for two reasons.


First, is that by adding regex to boolean, instead of the other way around - I can't use boolean regex for renaming files. I always use RegEx Rename, and boolean doesn't seem to work there.

And the second issue is that I have to precede every regex statement with the ">". That makes writing them more cumbersome, and it also means that sharing regex statements between programs is now a heck of a lot more difficult, because now I have to either add the little ">" characters, or remove them depending on which direction I'm going.

But, if boolean support was added to regex in general in XY, no special syntax would ever have to be used other than quoting, which is pretty standard. And it occured to me that I don't think you'd have to worry about someone ever searching for double quotes, for the same reason Mesh gave for the double asterisks - double quotes are illegal in filenames. And they don't have any special meaning in regex. Which means that if you added boolean support to every place in XY that supported regex, you'd have an easy way to detect if boolean logic would have to be applied - no double quotes, regular regex. Double quotes - boolean regex.

Mesh
Posts: 956
Joined: 24 Mar 2008 21:22

Re: Boolean RegEx

Post by Mesh »

admin wrote:
I added quoting. And kept the old way to work without quotes (using backslashes to escape critical sequences). Good solution. Thanks for pushing! :D

Whew! I thought I was just annoying you! Thanks for putting that in, I'll grab the beta and give it a try.

admin
Site Admin
Posts: 66310
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Boolean RegEx

Post by admin »

Demset wrote:I just gave the new version a shot. I'm thrilled that this has been added! And I'm also glad for the quoting support (thanks, Don! thanks, Mesh!).

But I have a problem because the regex support was added to the boolean search, instead of boolean support being added to regex. I will fervently vote for the latter, for two reasons.


First, is that by adding regex to boolean, instead of the other way around - I can't use boolean regex for renaming files. I always use RegEx Rename, and boolean doesn't seem to work there.

And the second issue is that I have to precede every regex statement with the ">". That makes writing them more cumbersome, and it also means that sharing regex statements between programs is now a heck of a lot more difficult, because now I have to either add the little ">" characters, or remove them depending on which direction I'm going.

But, if boolean support was added to regex in general in XY, no special syntax would ever have to be used other than quoting, which is pretty standard. And it occured to me that I don't think you'd have to worry about someone ever searching for double quotes, for the same reason Mesh gave for the double asterisks - double quotes are illegal in filenames. And they don't have any special meaning in regex. Which means that if you added boolean support to every place in XY that supported regex, you'd have an easy way to detect if boolean logic would have to be applied - no double quotes, regular regex. Double quotes - boolean regex.
I might be able to add "real" boolean regex to file find quickly. But not to all other RegExp places. Not now, because a major restructuring would be needed.

Mesh
Posts: 956
Joined: 24 Mar 2008 21:22

Re: Boolean RegEx

Post by Mesh »

admin wrote:
I might be able to add "real" boolean regex to file find quickly. But not to all other RegExp places. Not now, because a major restructuring would be needed.

I just gave the new beta a shot, and I'm finding the same limitations. But it's still a tremendous boon to be able to do this for searching, if nothing else. Thank you!


As for adding full support for this, I completely understand that it might not be a small project. Would you be willing to tackle this at some later point? If you watch US football, I think there's enough time during halftime nowadays to take on a project of some magnitude. :)

admin
Site Admin
Posts: 66310
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Boolean RegEx

Post by admin »

Mesh wrote:
admin wrote:
I might be able to add "real" boolean regex to file find quickly. But not to all other RegExp places. Not now, because a major restructuring would be needed.

I just gave the new beta a shot, and I'm finding the same limitations. But it's still a tremendous boon to be able to do this for searching, if nothing else. Thank you!


As for adding full support for this, I completely understand that it might not be a small project. Would you be willing to tackle this at some later point? If you watch US football, I think there's enough time during halftime nowadays to take on a project of some magnitude. :)
v7.70.0021 gives you Boolean RegEx for File Search pretty much as you envisioned. Enjoy! :D

Demset
Posts: 50
Joined: 02 Nov 2008 06:22

Re: Boolean RegEx

Post by Demset »

admin wrote:
v7.70.0021 gives you Boolean RegEx for File Search pretty much as you envisioned. Enjoy! :D

Sweet! That makes things so much easier! You're the greatest!

Question - if you were able to add Boolean support to RegEx, does that mean that RegEx Rename can use it as well?

admin
Site Admin
Posts: 66310
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Boolean RegEx

Post by admin »

Demset wrote:Question - if you were able to add Boolean support to RegEx, does that mean that RegEx Rename can use it as well?
Nope, this is for Find Files only. But I'll add it globally later. The code is there (obviously) but it needs a little restructuring to make it available all over the place. That will have to wait a bit...

Demset
Posts: 50
Joined: 02 Nov 2008 06:22

Re: Boolean RegEx

Post by Demset »

admin wrote:
Nope, this is for Find Files only. But I'll add it globally later. The code is there (obviously) but it needs a little restructuring to make it available all over the place. That will have to wait a bit...

Cool! You've already made my life so much easier by adding this for Find Files. If you're going to add this to RegEx Rename later on as well, I'm ecstatic!

Thanks!!!!!!

Post Reply