String source = "[[FirefoxDriver: firefox on WINDOWS (4520a9a1-c58b-4b34-ae3e-48613e6e7005)] -> xpath: //div[@class='page-title category-title']]";
System.out.println((source.substring(0, source.length() - 1).split("-> ")[1]));
//Output:
xpath: //div[@class='page-title category-title']
(source.substring(0, source.length() - 1) : this will remove the last element which is ']'(the last square bracket)
split("-> ")[1] : will split the string/element and return it's 1 element.
Improved little bit from @shresth josiSystem.out.println(source.split("-> ")[1]);
Output: xpath: //div[@class='page-title category-title']]
do you see the last ']'? that's the one I'm removing in the first step.