我有这个字符串:
"{ '_id' : ObjectId('4e85ba250364e5a1857ba2e4'),
'message' : '<user=animesh@strumsoft.com>, <action=create-flock>,
params=[<title=[smile.animesh@gmail.com, ram@strumsoft.com],
attendees=immediate, flockType=immediate, duration=30]>' }";
我试过跟着正则表达式:
private static String REGEXFinal = "<(.*?)>";
private static String REGEX2Final = "<(.*)>";
申请上面两个正则表达式后,最后出来是
user=a@a.com
action=create-flock
title=[a@a.com, b@b.com], attendees=immediate, flockType=immediate, duration=30]
但我想要按键/值格式的O / P,如
user a@a.com
action create-flock
title [a@a.com, b@b.com], attendees=immediate, flockType=immediate, duration=30]
怎么做?
答案 0 :(得分:0)
如果你有这个字符串
user=a@a.com
action=create-flock
title=[a@a.com, b@b.com], attendees=immediate, flockType=immediate, duration=30]
然后为什么不尝试这样做..
String str="user=a@a.com action=create-flock title=[a@a.com, b@b.com], attendees=immediate, flockType=immediate, duration=30]";
str = str.replaceAll("=", " ");
System.out.println(str);
答案 1 :(得分:0)
您可以为每一行使用以下代码:
line.replaceFirst("=", " ");