禁用 Gmail 可能会有误伤,毕竟人家目前还是第一大”免费“邮件服务商…… 结合2楼和3楼提到的发帖审核和检测的想法,在前端做一个检测让帖子发不出来,可能会简单一些?
我:Write a JavaScript function that will detect if an input contains any (commonly used) Simplified Chinese characters. If there is any, return true, if not, return false. The rule should only detect Simplified Chinese, but not include any characters from languages that are not Simplified Chinese, such as Japanese, Korean, or Vietnam characters. Remove all punctuation symbols from any of these languages first.
GPT-4:
function hasSimplifiedChinese(input) {
// Remove punctuation symbols from the input
const punctuationRegex = /[\u3000-\u303F\uFF00-\uFFEF]/g;
const cleanedInput = input.replace(punctuationRegex, '');
// Define the range for commonly used Simplified Chinese characters
const simplifiedChineseRegex = /[\u4E00-\u9FFF]/;
// Check if the cleaned input contains Simplified Chinese characters
return simplifiedChineseRegex.test(cleanedInput);
}
// Example usage
console.log(hasSimplifiedChinese("Hello, 世界!")); // Returns true
console.log(hasSimplifiedChinese("こんにちは")); // Returns false (Japanese)
console.log(hasSimplifiedChinese("안녕하세요")); // Returns false (Korean)
console.log(hasSimplifiedChinese("Chào bạn!")); // Returns false (Vietnamese)