I have a path string something like '/foo/bar1/bar2/test.txt'. I want to retrieve just '/foo/bar1/' from the string and want to ignore the rest. I tried doing that with \/([\w\s]+)\/|,(?!\w)+? but that didn't help.
Can someone help me with this ?
Thanks in advance
/foo/bar1/? For regex, there must be a strict indicator for selecting the right part. Or for eumiro's answer, change in the number of/or changing the string might resolve a wrong answer.. What do you really try to do here?...