![](/img/trans.png)
[英]Counting the number of occurrences of a substring within a string in PostgreSQL
[英]Getting all the occurrences of a substring within a string
如何獲取 PostgreSQL 中字符串中出現的所有 substring?
我有一個 ID 字符串:
BS Score xxxxxxx075SCxxxBS Score xxxxxxx062SCxxxBS Score xxxxxxx115SCxxx
我想獲取 ID 字符串中的數字,因此結果如下所示:
您可以使用regexp_matches
:
select id intl, regexp_replace(v[1], '^0+', '') values from tbl
cross join regexp_matches(id, '(\d+)', 'g') v
見小提琴。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.