Reputation: 5182
Let's assume this paths:
"...../site/configurationEN/database"
"....../site/configurationDE/database"
"....../site/configurationFR/database"
...
"....../site/configurationXX/database"
where XX can have many values for many countries.
How can i remove the XX characters from my path using regex replace and PHP? I need an expresion that would change any of the strings above in :
"....../site/configuration/database"
Thank you!
Upvotes: 1
Views: 402
Reputation: 3344
Try that :
<?php
$path = "site/configurationDE/database";
$newPath = preg_replace('#^(.*site/configuration)[A-Z]{2}#', '$1', $path);
?>
Upvotes: 1