Gaurav S
Gaurav S

Reputation: 1009

Regex for getting the date

The query

SELECT REGEXP_SUBSTR('Outstanding Trade Ticket Report_08 Apr 14.xlsx', '\_(.*)\.') AS FILE_DATE FROM DUAL

gives the OUTPUT:

_08 Apr 14.

Please advise the correct regex to be used for getting the date without the characters. I can use RTRIM and LTRIM but want to try it using regex.

Upvotes: 0

Views: 37

Answers (1)

Nir Alfasi
Nir Alfasi

Reputation: 53525

You can use:

SELECT REGEXP_SUBSTR('Outstanding Trade Ticket Report_08 Apr 14.xlsx', '\_(.*)\.', 
1, 1, NULL, 1) from dual

The last argument is used to determine which matched group to return.

Link to Fiddler

Upvotes: 1

Related Questions