[discussion]Better regex engine for XYplorer

Discuss and share scripts and script files...
bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

[discussion]Better regex engine for XYplorer

Post by bdeshi »

this is a discussion on best methods of improved regex support.
Heavily inspired by Marco's pYreX (http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=14436), and this feature request/discussion: http://www.xyplorer.com/xyfc/viewtopic.php?f=5&t=2473
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: [discussion]Better regex engine for XYplorer

Post by bdeshi »

http://www.xyplorer.com/xyfc/viewtopic. ... 36#p126888
So, AHK and AU3 can be a nice candidate as both use the PCRE engine. But a foolproof method has to be discovered for returning multiple matches.

How do you people think about an UDF like this: example_matcher($string, $pattern, $returngroup)
This way you only get one match returned at once. A separate matchcounter() function can be written with obvious agenda.

Or, what's a good candidate for the match separator? is the null character any good?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [discussion]Better regex engine for XYplorer

Post by highend »

The problems are:

- It must be bundled with XYplorer, otherwise it's useless (or you can only use it for yourself - at least I don't think that a normal user wants to get (download / install) another regex engine because your script relies on it)
- It must be affordable -> possible price increase of XY
- Even if it's freeware, do the license terms allow the bundling with a commercial application?
One of my scripts helped you out? Please donate via Paypal

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: [discussion]Better regex engine for XYplorer

Post by bdeshi »

come on, it's INTERESTING. That's a great reason!
Besides if it's impressive enough, Don might include it with XYplorer. That's what happened to CtxMenu64. My understanding is that it was made by Mesh.

edit: and I know that "the PCRE library is free, even for building proprietary software." http://pcre.org/
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [discussion]Better regex engine for XYplorer

Post by highend »

come on, it's INTERESTING. That's a great reason!
Sure.

And I'd like to see a better regex engine than the vbscript.dll. Lookbehinds are a really nice feature.

Let's see if Don has to say anything about that matter :beer:
One of my scripts helped you out? Please donate via Paypal

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

Re: [discussion]Better regex engine for XYplorer

Post by admin »

Sorry guys, but I got other plans. Many of them. No time for regex.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: [discussion]Better regex engine for XYplorer

Post by SkyFrontier »

From a regex' new user's perspective (I finally took some time to understand how regex works), the only thing worth in an XY own bettering approach would be (old idea, can't find where it's posted - if it is) an innovative (oh!, such a badly overused word...) GUI which would gently drive the user in finding a proper regex pattern. The only solution I found on this direction is RegexMatch (external link), which demands learning its own mechanics for a proper use of it.

Of course this kind of deviates from OT, but I had to take the opportunity.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: [discussion]Better regex engine for XYplorer

Post by bdeshi »

Maybe I should clarify, I wanted to discuss how to do it ourselves, as a scripting user function....
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Stef123

Re: [discussion]Better regex engine for XYplorer

Post by Stef123 »

@Sky
when using RegExMagic or RegExBuddy, what flavor do you pick? PCRE? Perl?
(@Sammay, sorry for hijacking your original intention even further - just had to squeeze in this question, it's important to me atm)

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: [discussion]Better regex engine for XYplorer

Post by SkyFrontier »

I stopped at the video demo. The magic was too obscure to my taste... :roll:
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Stef123

Re: [discussion]Better regex engine for XYplorer

Post by Stef123 »

SkyFrontier wrote:I stopped at the video demo. The magic was too obscure to my taste... :roll:
:lol: :lol:
Well, I am growing ever more desperate, there's got to be an easier way to come to grips with RegEx, or more specifically in my case, with renaming in XY. Just saw your other learn-teach-copewith-RegEx thread, see you there....

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: [discussion]Better regex engine for XYplorer

Post by Marco »

SammaySarkar wrote:http://www.xyplorer.com/xyfc/viewtopic. ... 36#p126888
So, AHK and AU3 can be a nice candidate as both use the PCRE engine. But a foolproof method has to be discovered for returning multiple matches.

How do you people think about an UDF like this: example_matcher($string, $pattern, $returngroup)
This way you only get one match returned at once. A separate matchcounter() function can be written with obvious agenda.

Or, what's a good candidate for the match separator? is the null character any good?
Python and AutoIt return arrays, while XY is constrained to strings instead.
When I wrote pYreX I resorted to something like

Code: Select all

length of entity #1|length of entity #2|...|length of entity #last<white space>entity #1entity #2...entity #last
which is conceptually correct but not practical.
I should find a way to verify whether a separator can be part of a match of the used regex, so that you know if a separator is fine for that particular case or the more advanced approach needs to be used.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: [discussion]Better regex engine for XYplorer

Post by bdeshi »

hmm, how about if we use "||" as separator, and any pipes in the matches are escaped as \| ?
then a gettoken will be able to pick any match reliably, since there can't be two consecutive |'s in them.
And there has to be only one extra step of de-escaping those pipes. replace(gettoken('match1||match2 \|\| with \\| pipes||match3',2,'||'), '\|','|')
any flaws?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: [discussion]Better regex engine for XYplorer

Post by bdeshi »

I've started to write a small autoIt3 utility called xypcre, and thought of these UDFs
pcrematch(string, pattern, separator(two chars), [returnmatch]),
pcrereplace(string, pattern, replacement),
pcrecapture(string, pattern, returngroup)
pcresplit(string, pattern, separator(two chars))
any other functions that would be useful? And/Or better formats for these UDFs?

XY and xypcre communicates using wm_copydata.
I'm not very familiar with AutoIt, so any help will be welcome.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: [discussion]Better regex engine for XYplorer

Post by Marco »

SammaySarkar wrote:hmm, how about if we use "||" as separator, and any pipes in the matches are escaped as \| ?
then a gettoken will be able to pick any match reliably, since there can't be two consecutive |'s in them.
And there has to be only one extra step of de-escaping those pipes. replace(gettoken('match1||match2 \|\| with \\| pipes||match3',2,'||'), '\|','|')
any flaws?
Mmh, clever idea, I approve :)
So the flow would be: string + regex > I obtain an array of matches > I "replace/escape" all the '|' with '\|' in the matches while they're still contained in the array > I flatten the array using '||' as separator between elements.
Correct?
SammaySarkar wrote:I've started to write a small autoIt3 utility called xypcre, and thought of these UDFs
pcrematch(string, pattern, separator(two chars), [returnmatch]),
pcrereplace(string, pattern, replacement),
pcrecapture(string, pattern, returngroup)
pcresplit(string, pattern, separator(two chars))
any other functions that would be useful? And/Or better formats for these UDFs?

XY and xypcre communicates using wm_copydata.
I'm not very familiar with AutoIt, so any help will be welcome.
pcrematch = ?
pcrereplace = the analogous of regexreplace()
pcrecapture = ?
pcresplit = ?

I'd love to help, if possible :)
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

Post Reply