当从数据库和rest服务获取记录时,
内部调动的ICT0637256入职调查问卷&ICT0637256
内部调动的ICT0637256入职调查问卷&ICT0637256
我在网上搜索发现\u000B是行表格。
现在,在soap服务级别上,我试图替换Rest服务中的字符:
public String replaceUnnecessaryCharacters(String text) {
if(StringUtils.isNotEmpty(text)) {
text = text.replaceAll("\\\\u000B", " ");
text = text.replaceAll("", " ");
text = text.replaceAll("<0x0b>", " ");
text = text.replaceAll("\\^K", " ");
}
return text;
}
if(task.getProjectId() == 5130764) {
LOG.info("getTasks: DescriptionDetails:5130764" + task.getDescription()); //<-- This comes from Rest API in code
LOG.info("getTasks: DescriptionDetails:5130764" + replaceUnnecessaryCharacters(task.getDescription())); <--- Here it doesn't show \u00B but blank space
}soapResponsetsk.setTaskDescription(replaceUnnecessaryCharacters(task.getDescription()));
我好像迷路了,怎么用Java来替换这个字符呢?你能给我建议一下怎么修理吗?
发布于 2022-02-10 11:50:15
因为您没有真正使用regex语法(比如+
*
量词、\w
字符类等等)而不是replaceAll
,您可以使用replace
方法。
另外,由于您想用另一个字符替换单个字符,所以可以使用replace(char oldChar, char newChar)
如下
text = text.replace('\u000B', ' ');
https://stackoverflow.com/questions/71063896
复制相似问题