I am useless at Regex and I want to remove parts of a URL that are not always consistent.
The URL might be:
www.test.com /en/ restOfPath
or
www.test.com /en/en_gb/ restOfPath
Then depending on the country values might change to:
www.test.com /es/ restOfPath
or
www.test.com /es/es_es/ restOfPath
I am therefore looking to alway remove, the parts in bold, so that I can split the remained of the path, to create a logical naming that is language/location agnostic.
I am doing this as a work around to build out a data layer until the client can implement it properly when they launch their new website. I have managed to build an if else statement as a workaround which is a bit clunky but would like a cleaner solution.