What about to add Java SE string functions String.matches(String
regex) and String.replaceAll(String regex, String replacement) into
built-in H2 string functions? I know I can create public static
version of these Java functions and add them into H2 as custom
function, but I think, it can be useful for general public.
Stepan
OK, I will add a feature request. In some situations it is possible to
use an index for MATCHES, so it really makes sense to add it to the
database core. How should the methods be called?
Suggestion: expression REGEXP matchExpression
Java: String.matches
PostgreSQL: expression ~ matchExpression
MySQL: expression REGEXP matchExpression
Oracle: REGEXP_LIKE(.., ..)
Suggestion: REGEXP_REPLACE(expression, regex, replacement)
Java: String.replaceAll
PostgreSQL: REGEXP_REPLACE
Oracle: REGEXP_REPLACE
Thomas
On Jul 9, 9:34 pm, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:
> In some situations it is possible to
> use an index for MATCHES, so it really makes sense to add it to the
> database core.
I think, that RegExp should not necessary use indexes directly. It can
be done by adding LIKE by user. So something like
select name from authors where name regexp_matches '^Neu(mann|hauser|
wirth)' and name like 'Neu%'
This approach can be less painful for implementation.
> How should the methods be called?
> Suggestion: expression REGEXP matchExpression
...better: expression REGEXP_MATCHES match Expression To have
consistent name with REGEXP_REPLACE
> Suggestion: REGEXP_REPLACE(expression, regex, replacement)
...Yes.
Thank You. Stepan
> I think, that RegExp should not necessary use indexes directly. It can
> be done by adding LIKE by user. So something like
>
> select name from authors where name regexp_matches '^Neu(mann|hauser|
> wirth)' and name like 'Neu%'
OK, I will implement it without index usage first. Probably index
usage will be added at some point.
> ...better: expression REGEXP_MATCHES match
Yes, but this is already used by PostgreSQL (as a function). I don't
want to add a feature which would make H2 incompatible with another
database if possible.
Thomas
...Yes, according to demand of users and Your spare time ;-)
> > ...better: expression REGEXP_MATCHES match
>
> Yes, but this is already used by PostgreSQL (as a function). I don't
> want to add a feature which would make H2 incompatible with another
...OK, it sounds reasonable. Go for it!
Thank You. Stepan