sqlean icon indicating copy to clipboard operation
sqlean copied to clipboard

regexp_replace error

Open ve3meo opened this issue 3 years ago • 7 comments

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?

ve3meo avatar Sep 08 '22 15:09 ve3meo

Which sqlean version are you using?

nalgeon avatar Sep 08 '22 17:09 nalgeon

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.

ve3meo avatar Sep 08 '22 19:09 ve3meo

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.

ve3meo avatar Sep 08 '22 20:09 ve3meo

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.

nalgeon avatar Sep 08 '22 21:09 nalgeon

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).

ve3meo avatar Sep 09 '22 01:09 ve3meo

This is quite important, IMO. Any intension of updating this method to handle multiple replacements?

natilivni avatar Nov 24 '22 19:11 natilivni

I will fix it, as soon as I have time.

nalgeon avatar Nov 24 '22 22:11 nalgeon

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.

nalgeon avatar Feb 03 '23 14:02 nalgeon

Fixed for Windows in 0.18.1. Now regexp_replace() replaces all occurrences of a match.

nalgeon avatar Feb 03 '23 15:02 nalgeon