Regarding the REG_EXTRACT() call: the format is "wrong" insofar that the format string must contain all the "superfluous" characters as well, meaning you would need something like this (assuming that the part before the date will always be "some text" plus a minus sign):
Reg_Extract( File_Name, '[^-]*-(\d+)-.*.txt', 1)
What does that mean?
First there's some "noise" up to the first minus character (this "noise" never contains a minus character itself).
Then there are some digits which we want to extract (hence the parentheses "(...)" around the \d+).
Finally there's one more minus sign followed by some arbitrary characters followed by ".txt".
BTW assuming that the two minus signs always enclose the date, you can use SUBSTR() to get the date. Do it this way:
Variable port v_pos_minus_1 type Integer:
InStr( File_Name, '-')
Variable port v_pos_minus_2 type Integer:
InStr( File_Name, '-', 1, 2)
Variable (or output) port type String:
SubStr( File_Name, v_pos_minus_1 + 1, v_pos_minus_2 - v_pos_minus_1 - 1)
This will return the substring of "File_Name" from the character following the first minus sign up to (but not including) the second minus sign.
If the two minus signs cannot be used as indicators for the position of the date, then please tell us exactly what these file names may consist of.
Not sure why Reg_Extract( File_Name, '[^-]*-(\d+)-.*.txt', 1) is not working it is just giving Null value.
but i used Substring to capture date portion.