【发布时间】:2015-11-13 08:13:01
【问题描述】:
我有一个字符串:
100-200-300-400
我想将破折号替换为“,”并添加单引号使其变为:
'100','200','300','400'
我当前的代码只能将“-”替换为“,”,我怎样才能加上单引号?
String str1 = "100-200-300-400";
split = str1 .replaceAll("-", ",");
if (split.endsWith(","))
{
split = split.substring(0, split.length()-1);
}
【问题讨论】:
标签: java string replaceall