Regular expression on a string problem.

Поиск
Список
Период
Сортировка
От Paul Mendoza
Тема Regular expression on a string problem.
Дата
Msg-id b5baf96a0709071553u1f05d48dm738bfb7b7cc1f6c1@mail.gmail.com
обсуждение исходный текст
Ответы Re: Regular expression on a string problem.  (Richard Huxton <dev@archonet.com>)
Список pgsql-general
Here is a problem I'm having with a function I've created. It should be returning a varchar value no matter what the input is but I'm getting a null value back. Then it says in the error that I'm using "nonstandard use of escape in a string literal at character 9". What do you think this should be changed to?

Query OK (0.45 sec)
Return Value: NULL
WARNING:  nonstandard use of escape in a string literal at character 9
HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.
QUERY:  SELECT  '/(\.PR\.)|(\.PR$)/'
CONTEXT:  PL/pgSQL function "clean_name" line 17 at assignment


Here is the function. p_text is a varchar that might have "PR" in it.

DECLARE
       var_regex_pattern varchar;
     

BEGIN


   
     -- If "PR" is not in the text variable.
     IF position('PR' in p_text) = 0 THEN
        var_regex_pattern = '/\./';
        RETURN substring(p_text from var_regex_pattern);
     END IF;
   
     IF position('PR' in p_text) > 0 THEN
        -- If "PR" is in the text variable.
        var_regex_pattern = '/(\.PR\.)|(\.PR$)/';
        RETURN substring(p_text from var_regex_pattern);
     END IF;
   

END;

В списке pgsql-general по дате отправления:

Предыдущее
От: Robert Fitzpatrick
Дата:
Сообщение: Left joining table to setof function
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: Query with "like" is really slow