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.
加载中,请稍侯......
精彩评论