I have a string
String origStr = "/unwanted/wanted1/wanted2/and_so_on"
i want to make this as
String finalStr = "wanted1/wanted2/and_so_on"
I thought of doing that using regEx in Java. But struck on this.
你可以做这样的事情 -
String str = "/unwanted/wanted1/wanted2/and_so_on";
String temp = str.substring(str.indexOf("/", 1)+1);
System.out.println(temp);
origStr.replaceFirst("/[^/]+/", "");
应该管用
不使用正则表达式。您可以使用split("/")
方法将其制成字符串数组。并削减第一个元素。
String [] arr= origSTr.split("/");
根据需要使用此 arr。