gna*_*ket 9 postgresql substring pattern-matching
我有一个字符串,说:
Product Description [White]
我想White使用PostgreSQL子串函数从该字符串中提取括号内的任何内容(在本例中).我可以使用它来工作regexp_matches,但是返回一个我不想要的数组,除非我别无选择.
我试过了:
substring('string' from '[(.)]') >>> NULLsubstring('string' from '\[(.)\]') >>> NULLsubstring('string' from '\\[(.)\\]') >>> NULL但这有效:
substring('string' from 'W(.)i]') >>> h 我究竟做错了什么?
a_h*_*ame 13
(.) 仅匹配单个字符,但您希望匹配多个字符.
所以你需要 (.+)
substring('Product Description [White]' from '\[(.+)\]')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7687 次 |
| 最近记录: |