开发者

How to work with first item of array?

SELECT regexp_matches('abc', '[0-9]*');

The query above returns text[] and need to check, whether it found any (i don't care which) matches or none.

So in case above i get {""}, how can i get "boolean" value, which tells me if it matches something or nothing?

This seems not work:

SELECT regexp_matches('abc', '[0-9]*') = '{}';

开发者_StackOverflow社区


Use the ~ operator:

SELECT 'abc' ~ '[0-9]*';

Alternatively, you could pull out the first item like this:

SELECT (regexp_matches('abc', '[0-9]*'))[1] = ''; -- True if it didn't match

Note the extra parentheses and that the array is indexed starting at 1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜