I have a string from which I want to extract a certain part:
Original String: /abc/d7_t/g-12/jkl/m-n3/pqr/stu/vwx
Result Desired: /abc/d7_t/g-12/jkl/
The number of characters can vary in the entire string. It has alphabets, numbers, underscore and hyphen. I want to basically cut the string after the 5th “/”
I tried a few regex, but it seems there is some mistake with the format.
If a non-regexp approach is acceptable, how about this:
Where
sif your string (in your case:/abc/d7_t/g-12/jkl/m-n3/pqr/stu/vwx).Then
should work. Not as compact as a regexp, but some people may find it clearer.