sqlean
sqlean copied to clipboard
regexp_replace error
This query in SQLiteSpy and the equivalent in Notepad++
SELECT regexp_replace('abcde','[bd]','_')
yields the result:
a_c_e
as I would expect.
The extension when added to SQLite Expert Personal 64 gives a different result:
a_cde
Is the app wrong or the extension?
Which sqlean version are you using?
I don't know where to find a version. I downloaded sqlean-win-x64.zip and the re.dll in it was modified 2022-09-07 10:48 PM. The ZIP file properties show it was created September 7, 2022, 9:55:36 PM. I don't think either of those is meaningful; the latter may refer to the download time and maybe the former (showing as later) might be from a time zone some hours ahead as I don't understand how it can be later.
The re.dll extension loaded on SQLiteStudio 3.3.3 gives the same erroneous result as in SQLite Expert Personal 64 so it is clearly the extension that is at fault. SQLiteSpy and Notepad++ must use different source code.
The current version of regex_replace replaces only the first occurrence, so the a_cde result is expected.
I might change this behavior in one of the future versions for consistency with the built-in replace.
That would be desirable for consistency with almost every other implementation of regexp_replace. Their default is to replace all occurrences of a match. Some have options or a different function name to replace just the first occurrence (or the first n).
This is quite important, IMO. Any intension of updating this method to handle multiple replacements?
I will fix it, as soon as I have time.
The issue is fixed with the new regexp extension in 0.18.0. Unfortunately, it does not support Windows at the time. I'll let you know when it does.
Fixed for Windows in 0.18.1. Now regexp_replace() replaces all occurrences of a match.