import java.util.regex.Matcher;
import java.util.regex.Pattern;
private static final String EMOJI_PATTERN = "[\\uD83C-\\uDBFF\\uDC00-\\uDFFF]+";
public static boolean containsEmoji(String text) {
if(text.isEmpty()){
return false;
}
Pattern pattern = Pattern.compile(EMOJI_PATTERN);
Matcher matcher = pattern.matcher(text);
return matcher.find();
}
😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄
😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅😅
public ResponseData<Object> save(@RequestParam(value = "aa", required = false) String aa,
@RequestParam(value = "bb", required = false) String bb,
@RequestParam(value = "remark", required = false) String remark,
@RequestParam(value = "projectId", required = false) Integer projectId,
@RequestParam(value = "location", required = false) String location,
@RequestParam(value = "cc", required = false) String cc,
@RequestParam(value = "dd", required = false) String dd,
@RequestPart(value = "files", required = false) List<MultipartFile> files) {
//小程序输入表情会自动带个?剔除即可
remark = remark.replace("�","");
cc = cc.replace("�","");
dd = dd.replace("�","");
if(containsEmoji(remark) || containsEmoji(cc) ||containsEmoji(dd)){
return new ErrorResponseData<>("500", "输入内容不能包含表情符号!", "error");
}