Page 1 of 3

[discussion]Better regex engine for XYplorer

Posted: 31 Jul 2015 19:32
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

Re: [discussion]Better regex engine for XYplorer

Posted: 31 Jul 2015 19:36
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?

Re: [discussion]Better regex engine for XYplorer

Posted: 31 Jul 2015 19:39
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?

Re: [discussion]Better regex engine for XYplorer

Posted: 31 Jul 2015 19:43
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/

Re: [discussion]Better regex engine for XYplorer

Posted: 31 Jul 2015 20:44
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:

Re: [discussion]Better regex engine for XYplorer

Posted: 31 Jul 2015 20:47
by admin
Sorry guys, but I got other plans. Many of them. No time for regex.

Re: [discussion]Better regex engine for XYplorer

Posted: 31 Jul 2015 21:24
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.

Re: [discussion]Better regex engine for XYplorer

Posted: 01 Aug 2015 06:55
by bdeshi
Maybe I should clarify, I wanted to discuss how to do it ourselves, as a scripting user function....

Re: [discussion]Better regex engine for XYplorer

Posted: 01 Aug 2015 11:26
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)

Re: [discussion]Better regex engine for XYplorer

Posted: 01 Aug 2015 11:51
by SkyFrontier
I stopped at the video demo. The magic was too obscure to my taste... :roll:

Re: [discussion]Better regex engine for XYplorer

Posted: 01 Aug 2015 11:56
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....

Re: [discussion]Better regex engine for XYplorer

Posted: 01 Aug 2015 15:50
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.

Re: [discussion]Better regex engine for XYplorer

Posted: 01 Aug 2015 16:09
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?

Re: [discussion]Better regex engine for XYplorer

Posted: 03 Aug 2015 12:35
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.

Re: [discussion]Better regex engine for XYplorer

Posted: 03 Aug 2015 16:02
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 :)