understanding postgresql regex in query -


    select substring(fld_path || fld_filename '#\"%#\".zip$' '#') file tbl_files 

im working on elses code , getting unexpected behaviour , cant work out means. havent done regular expression stuff.

can tell me query returning? thanks

you can see http://www.postgresql.org/docs/current/static/functions-matching.html substring function 3 parameters, substring(string pattern escape-character), provides extraction of substring matches sql regular expression pattern. similar to, specified pattern must match entire data string, or else function fails , returns null. indicate part of pattern should returned on success, pattern must contain 2 occurrences of escape character followed double quote ("). text matching portion of pattern between these markers returned.

some examples, #" delimiting return string:

substring('foobar' '%#"o_b#"%' '#')   oob substring('foobar' '#"o_b#"%' '#')    null 

ithink shold remove \ in patten.

digoal=# select substring('abcdefg' '#\"%#\"g%' '#');  substring  -----------  (1 row)  digoal=# select substring('abcdefg' '#"%#"g%' '#');  substring  -----------  abcdef (1 row) 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -