Question: the goal is to take the numbers in between 2 dashes and I was able to do that but the issue is that I need to remove the leading zero to the returned value. How can I incorporate the LTRIM function or other functions without removing all zeros?

Sample:

```
123-010-456

```

Results should be 10

```
SELECT[Phone],
REPLACE(SUBSTRING([Phone], CHARINDEX('-', [Phone]), CHARINDEX('-', [Phone])),'-','') AS substring
FROM [SalesLT].[Customer] 

```

Answer: 
I would have a different approach for more flexibility

```py
import os
from datetime import datetime
from pprint import pprint

def quick_str_to_date(s: str) -> datetime:
    return datetime.strptime(s, "%Y-%m-%d")

def get_file_by_date_range(path: str, startdate: datetime or str, enddate: datetime or str) -> list:
    if type(startdate) == str:
        startdate = quick_str_to_date(startdate)
    if type(enddate) == str:
        enddate = quick_str_to_date(enddate)
    result = []   
    for root, dirs, files in os.walk(path):
        for filename in files:
            if filename.startswith("BANK_NIFTY_5MINs_") and filename.lower().endswith(".csv"):
                file_date = datetime.strptime(os.path.basename(filename), "BANK_NIFTY_5MINs_%Y-%m-%d.csv")
                if startdate <= file_date <= enddate:
                    result.append(filename)
    return result

print("all")
pprint(get_file_by_date_range("/full/path/to/files", "2000-01-01", "2100-12-31"))

print("\nfebuari")
pprint(get_file_by_date_range("/full/path/to/files", "2020-02-01", "2020-02-28"))

print("\none day")
pprint(get_file_by_date_range("/full/path/to/files", "2020-02-01", "2020-02-01"))

```

**output**

```none
all
['/full/path/to/files/BANK_NIFTY_5MINs_2020-02-02.csv',
 '/full/path/to/files/BANK_NIFTY_5MINs_2020-02-28.csv',
 '/full/path/to/files/BANK_NIFTY_5MINs_2020-03-01.csv',
 '/full/path/to/files/BANK_NIFTY_5MINs_2020-03-31.csv',
 '/full/path/to/files/BANK_NIFTY_5MINs_2020-02-01.csv']

febuari
['/full/path/to/files/BANK_NIFTY_5MINs_2020-02-02.csv',
 '/full/path/to/files/BANK_NIFTY_5MINs_2020-02-28.csv',
 '/full/path/to/files/BANK_NIFTY_5MINs_2020-02-01.csv']

one day
['/full/path/to/files/BANK_NIFTY_5MINs_2020-02-01.csv']

```
If you want to do it with regex, here it is:

```
# replace `file.startswith(...) and file.endswith(...)`
re.match('BANK_NIFTY_5MINs_2020-(02|03|10|11|12)-[0-9]+', file)
###                              ^^^^^^^^^^^^^^ Feb, Mar, Oct-Dec

```

It's the most basic one to get you going, it might be improved.

---

But in your case I'd go with simple [glob](https://docs.python.org/3/library/glob.html):

```
all_files = glob.glob('./BANK_NIFTY_5MINs_2020-0[2-3]-*.csv')

```