的Kh-H0f2ZNYcxWYQtJvA-4jQ2rnm8WQSsVsNFkVRMYxpg-1417365081517,38606,"最佳 购买Co,Inc。",BBY01-694284011841
预期ans是
Kh-H0f2ZNYcxWYQtJvA-4jQ2rnm8WQSsVsNFkVRMYxpg-1417365081517" Best Buy Co,Inc。" BBY01-694284011841
但我正在
的Kh-H0f2ZNYcxWYQtJvA-4jQ2rnm8WQSsVsNFkVRMYxpg-1417365081517 "百思买公司 公司&#34。 BBY01-694284011841
我使用了分裂
String s =" ...";
String s [] = s.split(",");
答案 0 :(得分:1)
您可以对空白使用否定前瞻,以避免分割Best By Co
和Inc.
:
System.out.println(
Arrays.toString(
"Kh-H0f2ZNYcxWYQtJvA-4jQ2rnm8WQSsVsNFkVRMYxpg-1417365081517,38606,\"Best Buy Co, Inc.\",BBY01-694284011841"
.split(",(?!\\s)")
)
);
<强>输出强>
[Kh-H0f2ZNYcxWYQtJvA-4jQ2rnm8WQSsVsNFkVRMYxpg-1417365081517, 38606, "Best Buy Co, Inc.", BBY01-694284011841]