i am trying to extract the word in between the last /
and the second last /
- i.e. food in the following PHP example.
-
$string = https://ss1.xxx/img/categories_v2/FOOD/fastfood
(would like to replace$string
tofood
) -
$string = https://ss1.xxx/img/categories_v2/SHOPS/barbershop
(would like to replace$string
toshops
)
I am new to regex and tried /[^/]*$
- however that is returning everying after the last /
.. any help would be appreciated.. thanks!
I am using PHP.