knowsys / nemo

A fast in-memory rule engine.
https://knowsys.github.io/nemo-doc/
Apache License 2.0
61 stars 6 forks source link

Add REGEX string builtin function #498

Closed aidan-bailey closed 2 months ago

aidan-bailey commented 2 months ago

Mirrors SPARQL xsd:boolean REGEX (string literal text, simple literal pattern) function.

I think a separate function should be created for the ternary variation xsd:boolean REGEX (string literal text, simple literal pattern, simple literal flags) as was done for SUBSTR and SUBSTRING.

aidan-bailey commented 2 months ago

@aannleax informed me of the potential performance hit we'll take from compiling the same regular expression multiple times. I've found a well-used library that addresses this: regex-cache. Shall I integrate it or should we leave this optimising for future work?

matzemathics commented 2 months ago

@aannleax informed me of the potential performance hit we'll take from compiling the same regular expression multiple times. I've found a well-used library that addresses this: regex-cache. Shall I integrate it or should we leave this optimising for future work?

Given that the regex-cache crate basically just puts the regexes into a lru::LruCache, and does not appear to be active (last change from 4 years ago), I don't think we should take them as a dependency. We can probably build something similar really easily, but I think a first version of this PR could also be merged without this optimisation.

aidan-bailey commented 2 months ago

Hey hey hey, it's not abandoned, it's finished 😉