Search Postgresql Archives

Regular expression on a string problem.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux