javascript - Regex - Removing parts of URL path -
i useless @ regex , want remove parts of url not consistent.
the url might be:
www.test.com /en/ restofpath
or
www.test.com /en/en_gb/ restofpath
then depending on country values might change to:
www.test.com /es/ restofpath
or
www.test.com /es/es_es/ restofpath
i therefore looking alway remove, parts in bold, can split remained of path, create logical naming language/location agnostic.
i doing work around build out data layer until client can implement when launch new website. have managed build if else statement workaround bit clunky cleaner solution.
probably you
(?:\/([a-z]{2})(?:\/([a-z]{2}_[a-z]{2}))?) this example find first / 2 alpha after that, , / aa_aa construction.
i got code samples @ regex101
Comments
Post a Comment