javascript - 正则表达式查找字符串是否仅包含特殊字符或数字和特殊字符的混合
问题描述
我需要在 js 中编写一个正则表达式来验证字符串是否只包含特殊字符以及特殊字符和数字的混合。
我的意思是它不应该接受这些
- 123(只有数字)
- 123@#@$12(两者混合)
- @#$@$(仅限特价)
它可以接受
- 123fgfdg
- @#$dfgdfg
请考虑其他语言日语和韩语
我有这个代码
function ValidateValue(str){
if(trim(str).length == 0){
getMessage(7); //if string is empty
}if(/^[^a-zA-Z]+$/.test(str)){//check if the string contains special and digits
getMessage(21); //this part works fine for english but not for japanese or korean.
}if(IsInteger(trim(str))){
getMessage(8);// if string contains only numbers
}
}
解决方案
推荐阅读
- .net - EFCore cli 生成无用的迁移
- linux - 如何避免具有权限的文件????????? 在构建 docker 容器时
- python - CUDA 初始化:来自 cudaGetDeviceCount() 的意外错误
- c++ - Boost::units 非 SI 单位
- c++ - C++ 错误:从 'const void*' 到 'void*' 的无效转换 [-fpermissive]
- svelte - 如何在一个苗条的项目中使用 MathJax?
- reactjs - 我应该在平面列表中输入什么来获取那个 json API,我得到了响应,我可以 consol.log 它
- typescript - Inversify - 尝试在测试中实例化控制器时出错(使用 inversify-express-utils)
- android - 在 http 状态 < 200 || 时,kittinunf/fuel 无法恢复答案正文 > 299
- junit5 - @AfterAll 不会在所有测试结束时运行