<?php $test = <<<URLS https://example.com/cost-center/sub-one/sub-two/article-3/ https://example.com/cost-center/sub-one/sub-three/article-4 https://example.com/cost-center/sub-1/sub-two/sub-three/article-5/ 'https://example.com/cost-center/sub-one/sub-two/article-3/' 'https://example.com/cost-center/sub-1/sub-two/sub-three/article-5' "https://example.com/cost-center/sub-one/sub-three/article-4" "https://example.com/cost-center/sub-1/sub-two/sub-three/article-5/" URLS; echo preg_replace('#https://[^/]+/cost-center/\K([^/\s]+/)+(?=article)#', 'test/', $test);
You have javascript disabled. You will not be able to edit any code.