gpt4 book ai didi

java - 根据某些值在java中分割字符串

转载 作者:太空宇宙 更新时间:2023-11-04 07:22:15 25 4
gpt4 key购买 nike

我有以下字符串:

String verifyPaymentDetails = "{
2298597={mihpayid=403993715508098532, request_id=NULL, bank_ref_num=NULL, amt=53.77, disc=0.00, mode=CC, PG_TYPE=AXIS, card_no=512345XXXXXX2346, name_on_card=emu, udf2=0, addedon=2013-06-03 17:34:42, status=failure, unmappedstatus=failed, Merchant_UTR=NULL, Settled_At=NULL},
6503939={mihpayid=Not Found, status=Not Found}
}"

我想分割字符串并获取如下值:2298597={mihpayid=403993715508098532, request_id=NULL, bank_ref_num=NULL, amt=53.77, disc=0.00, mode=CC, PG_TYPE=AXIS, card_no=512345XXXXXX2346, name_on_card=emu, udf2=0, addedon=2013-06-03 17:34:42, status=failure, unmappedstatus=failed, Merchant_UTR=NULL, Settled_At=NULL},如何在 java 中使用 string.split 做到这一点?

分割值后,我替换了 {}值(value)。

请提供您的帮助来完成此操作。

谢谢

最佳答案

尝试

String verifyPaymentDetails = "{"
+ "2298597={mihpayid=403993715508098532, request_id=NULL, bank_ref_num=NULL, amt=53.77, disc=0.00, mode=CC, PG_TYPE=AXIS, card_no=512345XXXXXX2346, name_on_card=emu, udf2=0, addedon=2013-06-03 17:34:42, status=failure, unmappedstatus=failed, Merchant_UTR=NULL, Settled_At=NULL},"
+ "6503939={mihpayid=Not Found, status=Not Found}" + "}";
String[] split = verifyPaymentDetails.substring(1,
verifyPaymentDetails.length() - 2).split("(\\}, ?|=\\{)");

关于java - 根据某些值在java中分割字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19153315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com