Home > Software design >  Specific number of numerals with regex
Specific number of numerals with regex

Time:05-22

I need a regex expression (python) that will extract from the name of the file only the year and the month.

The example of the name of the files look like this: "JSON/42153_webz_2018_09_605eb2963f4da8b62af29efa8e82e7ab_0000001.json"

I need: "2018_09"

The syntax of the file name is always the same.

CodePudding user response:

You can use the expression - ([0-9]{4}_[0-9]{2})

CodePudding user response:

Also, this one should do the job : \d{4}_\d{2}

  • Related