从遵循模糊模式 SQL 的字符串中提取序列号 Netezza

extract serial from string that follow fuzzy pattern SQL Netezza

请给我一条日志消息,其中包含一个带有模糊模式的序列号,如下所示难以理解

|LogMsg                                                                                    |
|------------------------------------------------------------------------------------------|
|Customer Receive CPE Indoor. serial 21530369847SKA011094, user:ahmed.o.haraz              |
|Customer Receive CPE Indoor as change. serial :21530369847SK9078291, user:Abdullah.M160275|
|Customer Receive CPE Indoor. serial:ZTERRT1H9202990                                       |
|Customer Receive CPE Indoor. serial 21530369847SKB333996 .UserName :TEDST.mohamed.badry   |
|Customer Receive CPE Indoor as change. serial :21530373727skc298302, user:Frass.m195577   |
|Customer Receive CPE Indoor. serial 21530369847SKA267112 .UserName :seller.160002         |

我需要从下面的字符串中提取序列号

|Serial|
|21530369847SKA011094|
|21530369847SK9078291|
|ZTERRT1H9202990     |
|21530369847SKB333996|
|21530373727skc298302|
|21530369847SKA267112|

我使用 regexp_replace() 得到了提到的查询,但它遗漏了一些

select replace(replace(regexp_extract(logmsg, 'serial [^,]+'), 'serial ', ''), ':', '')

尝试

select get_value_varchar(
        regexp_extract_all_sp(logmsg,
          '(serial\s*:?)([^,\s]+)'),3) as serial
from serial;

它应该会给你想要的结果

        SERIAL
----------------------
 21530369847SKA011094
 21530369847SKA267112
 21530369847SKB333996
 21530369847SK9078291
 ZTERRT1H9202990
 21530373727skc298302
(6 rows)