Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.49k stars 170 forks source link

Use Python regex by default #1592

Closed Gravityzwell closed 6 years ago

Gravityzwell commented 6 years ago

Is there any way to switch CudaText behavior so it uses the Python regular expression engine for find/replace etc?

Preferably I want Matthew Barnetts regex module https://bitbucket.org/mrabarnett/mrab-regex

My understanding is CudaText currently uses: http://regexpstudio.com/en/regexp_syntax.html

This is apparently the authors approximation of Perl. I don't know what the differences are, and I did not see this info on the author's site, but my first test was to see if \K works and it doesn't.

Matthew Barnetts regex is well tested, well documented, good performance, and supports every major regex feature that I'm aware of. Matt's engine works for me at least as well as PCRE/Perl or the other top regex engines (.Net/Onig), to the extent I don't think further about it, but just add it to Python automatically.

Alexey-T commented 6 years ago

Cud uses RegExpr from FreePascal 3. I cannot switch to Python regex of course.

Alexey-T commented 6 years ago

@kvichans Maybe good for FindInFiles..

kvichans commented 6 years ago

Yes. FiF uses pure Python regexp. I vote to new options to switch core Find regexp to Python style

Gravityzwell commented 6 years ago

Ok, understood Python can't be used. Is there any way to implement PCRE, PCRE2, Perl, Ruby/Onig? I see searching the Free Pascal forums there is mention of pulling in PCRE in different ways. This: http://forum.lazarus-ide.org/index.php?topic=27323.0 looks to me like it references an external DLL (Windows I guess)

I prefer to see any well documented/supported engine, rather than some regex by some guy with a site. PCRE/Perl have decades of use, testing, and documentation. I do appreciate the work of the current regex, and if that is the only way, then fine, it's much better than nothing.

FYI I can say when I use Notepad++ the regex engine is Boost, and maybe not as well tested as PCRE, it's close. Definitely not a some guy on github thing.

Alexey-T commented 6 years ago

Is there any way to implement PCRE, PCRE2, Perl, Ruby/Onig?

Only if some programmer will make them for Freepascal. I use standard Freepascal RegExpr- most stable from all regex libs. https://github.com/Alexey-T/ATSynEdit/blob/master/atsynedit/atsynedit_regexpr.pas it is fork with tweaks.

Alexey-T commented 6 years ago

Freepascal- https://github.com/graemeg/freepascal/blob/master/packages/regexpr/src/regexpr.pas

Gravityzwell commented 6 years ago

That's nice, but I'd rather see a wrapper to a supported binary. https://www.pcre.org https://www.pcre.org/current/doc/html/pcre2.html ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

If you look at (which I have actually compiled previously): ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.zip start with pcre_exec.c and pcre_compile.c.

I don't feel qualified to glance at some guys regex implementation and be able to say anything about it. But a binary PCRE/PCRE2/Perl, then I know it is well tested over years.

Alexey-T commented 6 years ago

I need some ready Freepascal module, which uses your code and binary, ie Regex lib (i don't want to mess with C files)