Postgresql

PostgreSQL中的模式匹配?

  • June 22, 2015

我有一個字元串需要提取日期,

範例: S01_XXX001_000_min_01_ 20150526 T 123440583 .arc , S01_XXX001_000_ 20150526 T 123440583 _min_01.arc

基於像’ Numeric T Numeric ‘這樣的模式,

我正在嘗試使用以下 sql 進行提取,任何人都可以幫助我。

SQL:

select  substring('S01_ZAR001_000_min_01_20150526T123440583.arc','^\d')

select  substring('SAPCC_XX_ZZZ_BitClass_XXX_20150623T45656566456_XXX_XX_XXXXXX.arc' like '_%T%_',1,8)

select  substring('SAPCC_XX_ZZZ_BitClass_XXX_201506235T335656_XXX_XX_XXXXXX.arc','[^_]+([^0-9]{1,8})$')

SELECT SUBSTRING('XY1234Z', 'Y*([0-9]{1,3})');
select substr(
       substring('SAPCC_XX_ZZZ_Bit1T1Class_XXX_201506235T335656_XXX_XX_XXXXXX'
                 from 
                 '_[0-9]+T[0-9]+_'
                ), 2, 8
            )::date

引用自:https://dba.stackexchange.com/questions/104721