沃尔玛库存接口SKU码中特殊字符串的替换
An arbitrary alphanumeric unique ID, specified by the seller, which identifies each item. This will be used by the seller in the XSD file to refer to each item. Special characters in the sku needing encoding are: ':', '/', '?', '#', '[', ']', '@', '!', '$', '&', "'", '(', ')', '*', '+', ',', ';', '=', ‘ ’ as well as '%' itself if it's a part of sku. Make sure to encode space with %20. Other characters don't need to be encoded.
public static String getRegExSKU(String sku) {
if (Objects.nonNull(sku)) {
String regEx = "[`~!@#$%^&*() _\\+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(sku);
return m.replaceAll("%20");
}
return "sku is null";
}
java 正则替换各种特殊字符 ‘:‘, ‘/‘, ‘?‘, ‘#‘, ‘[‘, ‘]‘, ‘@‘, ‘!‘, ‘$‘, ‘&‘, “‘“, ‘(‘, ‘)‘, ‘*‘, ‘+‘, ‘,‘, ‘;‘,
最新推荐文章于 2024-11-25 16:15:24 发布
2181

被折叠的 条评论
为什么被折叠?



