postgres=# select replace('you are a man,old man','man','woman'); you are a woman,old woman
postgres=# select translate('you are a man,'woman'); you ore o wom,old wom可以看出,translate把替换后的子串截断成原来的子串的长度。
2. trim相关的函数,消除两边的指定子串
> 替换两头的子串:
postgres=# select trim('xxxytrimyyyx','xy'); trim
postgres=# select trim(both 'xy' from 'xxxytrimyyyx'); trim
postgres=# select btrim('xxxytrimyyyx','xy'); trim
> 替换左边的子串
postgres=# select ltrim('xxxytrimyyyx','xy'); trimyyyx postgres=# select trim(leading 'xy' from 'xxxytrimyyyx'); trimyyyx
> 替换右边的子串
postgres=# select rtrim('xxxytrimyyyx','xy'); xxxytrim postgres=# select trim(trailing 'xy' from 'xxxytrimyyyx'); xxxytrim
3.抽取字符串
postgres=# select substring('helloworld',2,4); ello postgres=# select substr('helloworld',4); ello
参考地址: http://www.cnblogs.com/stephen-liu74/archive/2012/05/02/2294071.html
原文地址:https://www.jb51.cc/postgresql/195411.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。