Pattern matching in PostgreSQL? I have a string in which need to extract the date, 

Example: S01_XXX001_000_min_01_20150526T123440583.arc ,
S01_XXX001_000_20150526T123440583_min_01.arc

based on the pattern like 'Numeric T Numeric',

I am trying to extract with the below sql , can any one help me.

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