Reputation: 10159
suppose I have tree hierarchy string like this "/grand_parent/parent/child"
(three level) or "/parent/child"
(two level), "/child"
(one level) and I tried "^(/[^/]*)"
could extract the first level "/grand_parent"
, and wondering if I want to extract the first two levels if there exists,
e.g.
"/grand_parent/parent"
for "/grand_parent/parent/child"
"/parent/child"
for "/parent/child"
"/child"
what is the suggested regular expression?
Upvotes: 0
Views: 179