的是有一些更好的方法regexp_matches比的結果修剪{""}
:regexp_matches更好的辦法來擺脫返回大括號
trim(trailing '"}' from trim(leading '{"' from regexp_matches(note, '[0-9a-z \r\n]+', 'i')::text))
的是有一些更好的方法regexp_matches比的結果修剪{""}
:regexp_matches更好的辦法來擺脫返回大括號
trim(trailing '"}' from trim(leading '{"' from regexp_matches(note, '[0-9a-z \r\n]+', 'i')::text))
regexp_matches()
返回所有匹配的數組。數組的字符串表示形式包含花括號,這就是爲什麼你得到它們。
如果你只是希望所有匹配項的列表,你可以使用array_to_string()
將結果轉換成「簡單」的文本數據類型:
array_to_string(regexp_matches(note, '[0-9a-z \r\n]+', 'i'), ';')
如果你只在第一場比賽感興趣,你可以選擇陣列的第一個元素:
(regexp_matches(note, '[0-9a-z \r\n]+', 'i'))[1]
我想擺脫文本字段中的垃圾字符,所以'array_to_string'就是我所需要的。感謝您的澄清! –
非常感謝你的工作:D –
'regexp_matches'返回所有匹配的數組。數組的字符串表示形式包含花括號。問題是你想對每個數組元素做什麼?你如何使用'regexp_match()'函數的結果? –