Regex to get 7 to 8 Consecutive numbers

I have this series of files that I need to extract a certain number from. The files are formatted as
(Customer Name)(dash)(Branch)(space)(date in MMDDYYYY format).

I need to extract the date in MMDDYYYY format and to date parse it. I did a substring to get the last digits before, but some files will have a “-” in the end, so I am thinking of using regex this time. The problem is, some files aren’t formatted as MMDDYYYY but MDDYYYY. In short, the client sometimes forgets to add a “0” for the month. I can get the the last 8 digits by using this\b\d{8} but I am hoping to see if it is possible to get from 7 to 8 digits.


Can you try the following pattern?


Or the following will also help you.



1 Like

Thanks! \b\d{7,8} works.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.