1

我有以下字符串:

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 执行此操作?

在拆分值后,我替换了{}in 值。

请提供您的帮助。

谢谢

4

1 回答 1

1

尝试

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("(\\}, ?|=\\{)");
于 2013-10-03T07:37:54.903 回答