I'm trying to get the PCRE module working with my monetDB server.
I run the following:
CREATE OR REPLACE FUNCTION pcre_index(s string, pattern string) RETURNS integer EXTERNAL NAME pcre."index";
But when I run the function:
select pcre_index('this is a long string', '\\s');
I get the following error:
TypeException:user.main[6]:'pcre.index' undefined in: X_0:int := pcre.index(X_1:str, X_2:str);
I know other PCRE functions are working because when I run:
CREATE OR REPLACE FUNCTION pcre_imatch(s string, pattern string) RETURNS boolean EXTERNAL NAME pcre."imatch";
select pcre_imatch('this is a long string', '\\b\\s');
I get the following:
+-------+
| %2 |
+=======+
| true |
+-------+
I'm using this link to derive the function that I should write.
Please let me know what I am doing wrong. I am using MacOS and have installed monetdb via homebrew.
Thank you for your time and help.
You created your
pcre_indexin a correct way. The problem is thatpcre.indexrequires a typepcreas its first parameter.Use
pcre.patindexinstead:NB1: with
pcre.indexandpcre.patindex, the pattern comes first.NB2 the
R''syntax is preferable over the backslashesNB3
pcre.(pat)indexuses an SQL pattern to try to match the string, not a PCRE regular expression. That's why all those attempts with\sand\bfail: they're not SQL patterns. The interface to produce a PCRE value that could be used inpcre.(pat)indexwas removed in 2014.