How can i extract partial text from the URL

Suppose i get a URL in a String “
Now i have to extract “gp” which is there after and between “/”

So How do I get only the “gp”, and use it to input in other menu?

I might look into the split function but it would depend on more information. The split function returns a list of Strings breaking the given url string into parts based on the parameter–in this case the slash. The list of Strings starts at zero, so I think we want the 4th string but you can play with the number if it doesn’t produce the correct phrase.

myVar = url.split("/")[3]
WebUI.comment('my var is ' + myVar)

Note: the contents within the split function is using Regex, so sometimes you have to “escape” the reference, like:

myVar = url.split("\\/")[3]

Thanks a lot the solution worked for me