I have sample strings like below,
abc/def/ghi/test/yvw/syz
abc/fed/igh/test_123/wuvacv/zyxh
I want to get it like below
abc/def/ghi/test
abc/fed/igh/test_123
So what are the best way to follow for string manipulation
Thanks in advance.
I'm trying to split by "/" and put the words into an array and looping it.but stuck in middle. Here I cant use regex here cas last two words can be anything.
You can use a simple regex to match any text between the slashes:
Or you can split and rejoin like this: