[英]Getting all the occurrences of a substring within a string
How can I get all the occurrences of a substring within a string in PostgreSQL?如何获取 PostgreSQL 中字符串中出现的所有 substring?
I have this string for an ID:我有一个 ID 字符串:
BS Score xxxxxxx075SCxxxBS Score xxxxxxx062SCxxxBS Score xxxxxxx115SCxxx
And I would like to get the numbers in the string for the ID, so the result can look like this:我想获取 ID 字符串中的数字,因此结果如下所示:
You can use regexp_matches
:您可以使用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.