在两个特殊字符之间拆分字符串
Spliting a string between two special characters
我想在两个特殊字符之间拆分一个字符串。这是我的字符串
https://localhost:8080/app/EmailActivation&email=karthi622@gmail.com&hash=8be935b6-4f58-425f-a45d-f51ba9f67249
我只想要两个字符串,即电子邮件和散列。我的输出就像
karthi622@gmail.com
8be935b6-4f58-425f-a45d-f51ba9f67249
谁能帮我解决这个问题。
String in = " https://localhost:8080/app/EmailActivation&email=karthi622@gmail.com&hash=8be935b6-4f58-425f-a45d-f51ba9f67249";
String temp = in.substring(in.lastIndexOf("/") + 1);
String params[] = temp.split("&");
String email = params[1].substring(params[1].indexOf("=") + 1);
System.out.println(email);
String hash = params[2].substring(params[2].indexOf("=") + 1);
System.out.println(hash);
请查找以下代码:
String str = new String("https://localhost:8080/app/EmailActivation&email=karthi622@gmail.com&hash=8be935b6-4f58-425f-a45d-f51ba9f67249");
String email = new String(str.split("&")[1].replace("email=", ""));
System.out.println(email);
String hash = new String(str.split("&")[2].replace("hash=", ""));
System.out.println(hash);
字符串输入="https://localhost:8080/app/EmailActivation&email=karthi622@gmail.com&hash=8be935b6-4f58-425f-a45d-f51ba9f67249";
if(in.contains("email")&&in.contains("hash"))
{
String email = in.substring(in.indexOf("email=")+("email=").length(),in.lastIndexOf("&"));
String hash = in.substring(in.indexOf("hash=")+("hash=").length(),in.length());
System.out.println("email :"+email+" hash :"+hash);
}
我想在两个特殊字符之间拆分一个字符串。这是我的字符串
https://localhost:8080/app/EmailActivation&email=karthi622@gmail.com&hash=8be935b6-4f58-425f-a45d-f51ba9f67249
我只想要两个字符串,即电子邮件和散列。我的输出就像
karthi622@gmail.com
8be935b6-4f58-425f-a45d-f51ba9f67249
谁能帮我解决这个问题。
String in = " https://localhost:8080/app/EmailActivation&email=karthi622@gmail.com&hash=8be935b6-4f58-425f-a45d-f51ba9f67249";
String temp = in.substring(in.lastIndexOf("/") + 1);
String params[] = temp.split("&");
String email = params[1].substring(params[1].indexOf("=") + 1);
System.out.println(email);
String hash = params[2].substring(params[2].indexOf("=") + 1);
System.out.println(hash);
请查找以下代码:
String str = new String("https://localhost:8080/app/EmailActivation&email=karthi622@gmail.com&hash=8be935b6-4f58-425f-a45d-f51ba9f67249");
String email = new String(str.split("&")[1].replace("email=", ""));
System.out.println(email);
String hash = new String(str.split("&")[2].replace("hash=", ""));
System.out.println(hash);
字符串输入="https://localhost:8080/app/EmailActivation&email=karthi622@gmail.com&hash=8be935b6-4f58-425f-a45d-f51ba9f67249";
if(in.contains("email")&&in.contains("hash"))
{
String email = in.substring(in.indexOf("email=")+("email=").length(),in.lastIndexOf("&"));
String hash = in.substring(in.indexOf("hash=")+("hash=").length(),in.length());
System.out.println("email :"+email+" hash :"+hash);
}