I'm working on a regex, but I can't make it work as I'd like.
The strings, 2 examples :
- /download?standard=yes&file=France_new-aquitaine_deux-sevres_europe_2.obf.zip
- /download?standard=yes&file=Afghanistan_asia_2.obf.zip
I want to extract following parts :
- country (France)
- region (new-aquitaine)
- department (deux-sèvres)
- worldZone (europe)
My WIP regex :
/.*file=(?:(.*?)_{1})*?(?:\d\.obf\.zip)$/gi
Maybe there is a recursive way to handle it, I don't know.
Can you help or guide me ? Thanks.
Solved with :
/.*file=([^_]+)_(?:([^_]+)_)??(?:([^_]+)_)??([^_]+)_2\.obf\.zip$/g