Reputation: 3512
What I want to do is remove all instances of c_*/ where * could be any digit or character of any length.
$cano = 'www.example.com/example/example2/c_3/example4/';
$cano = preg_replace('c_*/', '', $cano);
I've always been bad with these cause I hardly use them...
Upvotes: 0
Views: 2140
Reputation: 670
Try this:
$cano = 'www.example.com/example/example2/c_3/example4/';
$cano = preg_replace('#(?:c_.[^/]/)+#', '', $cano);
Upvotes: 0
Reputation: 1569
I think this will do the trick.
$cano = preg_replace('#c_[^/]+/#', '', $cano);
The [^/]
matches any character that is not a forward slash, and the +
means "one or more" characters.
Upvotes: 3