Is there a way to create a regex function where i can ignore the forward slash and remove the first word after the forward slash?

30 views Asked by At

/saddlebrown-firm-leather-wallet this is my string , i want /firm-leather-wallet The regular expression i want to create should remove the first word of the string after the slash and return the string with the slash intact . this is my code

<?php
function remove($string) {
    $string = str_replace('/^\/[a-zA-Z]+-/', '', $string);
    return $string;
}
?>
0

There are 0 answers