Answer the question
In order to leave comments, you need to log in
How to get the last directory in a line?
You need to get the last directory from the link (it doesn’t matter if it’s a link or just a string)
Example:
https://site.ru/catalog/cat1/ you need to get cat1
https://site.ru/catalog/cat1/cat2/ you need to get cat2
https ://site.ru/catalog/cat1/cat2/cat3/ you need to get cat3
https://site.ru/catalog/cat1/cat2/cat3/cat4/ you need to get cat4
This means that the nesting is different, it can be like 1, and 10+, but you need to pull out the last one.
/(?:.(?!/))+$
everything works after the last one/
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question