My String has contains multiple * but i want to split using * at of the first index ~*{
of this regex but they have split all the sting which contains *?
Here is the current code:
String text="hdr_Tran_Id=CRDSUMMARY~*hdr_Ref_No=1~*res_Status=00000~*{\"ResErrMsg\":\"SUCCESS\",\"ResTxnRefCode\":\"CARDNUMLIST\",\"ResLocalTxnDtTime\":\"20190830173112\",\"ResCardNumList\":[{\"ResCardNumber\":\"47703601****5004\",\"ResStatusDesc\":\"OPEN NORMAL\",\"ResCardStatus\":\"00\",\"ResEMailId\":\"lokesh.v4@gmail.com\",\"ResBirthDate\":\"16-11-1987\"},{\"ResCardNumber\":\"60820101****2002\",\"ResStatusDesc\":\"OPEN NORMAL\",\"ResCardStatus\":\"00\",\"ResEMailId\":\"bhandarkarn@gmail.com\",\"ResBirthDate\":\"01-01-1950\"}";
public static String validation(String text){
System.out.println(text);
String[] newText=null;
String finalText=null;
if (text.contains("~")) {
newText=text.split("~*\\{");
System.out.println("length "+newText.length);
finalText=newText[1];
System.out.println("New Text "+newText);
System.out.println("Final Text "+finalText);
return finalText;
}
You can use
newText=text.split("~*\\{", 2);
Check String.split(java.lang.String regex, int limit) for reference
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.