我想对应该以abc:skp开头的字符串进行字符串匹配:并且在那之后只有数字。
这就是我希望在PostgreSQL上实现的。
例如,用于检查PL/pgSQL块中的true或false的字符串
- abc:skp:293043204 --此操作有效并返回true
- abc:skp:23 hj 29490--这是无效的,并返回false
如何在PL/pgSQL块中执行此操作,即
do $$
<<block_2740>>
---
end $$`
我已经尝试了以下的东西,但不工程的第二个
if TEXTREGEXEQ(item_pguid,'abc:skp:([0-9]+)') then
-- checking
end if;
1条答案
按热度按时间oxf4rvwz1#
参见https://www.postgresql.org/docs/13/functions-matching.html
如果愿意,您可以使用
~
文本操作符,或者使用regexp_matches
函数。下面是使用regexp_matches的示例。我还更正了您的正则表达式。您缺少终止匹配$
这将输出