javascript - Angular 中用于设置验证的正则表达式
问题描述
我在Angular中有这样的功能:
checkRegex() {
setTimeout(() => {
const regex = /^(?=.{8,})(?=.[A-Z])(?=.[a-z])(?=.[0-9])(?=.[!@#$%^&()=])([a-zA-Z0-9!@#$%^&()=-]+)$/g;
let checkListCondition = this.listCondition[0];
let checkValue = checkListCondition.value[0]
const matchRegex = checkValue.test(regex)
if (matchRegex) {
this.state.disableGroup.submitButton = false;
} else {
this.state.disableGroup.submitButton = true;
}
console.log('checkValue', checkValue);
}, 10);
}
我的期望是如果我输入这样的值:
<测试'
this.state.disableGroup.submitButton 将返回 false,如果我输入这样的值:
(成功^
this.state.disableGroup.submitButton 将返回 true
在我的代码中,你能帮我找出我的错误在哪里吗?谢谢你。我当前的代码不起作用。我需要你们的帮助
解决方案
推荐阅读
- here-api - 坐标高程图
- reactjs - 如何在执行 render() 之前从 reducer 获取 prop 值?
- javascript - 错误'不知道如何构建任务'konacha:serve'
- xamarin.android - 当用户滑动按钮时添加动画
- c# - 导出到excel后如何制作永远不会转换为日期的文本?
- python - 如何修复“在 `LogEntry.user` 上检测到潜在的不必要的急切负载”
- pandas - 如何在不拆分具有不同条件的数据框的情况下执行公式
- python-3.x - How to change a cell value of a column based on cell value of another corresponding columns
- python - 向 cv2.imshow() 提供大 (4017*3007) 图像不会显示整个图像
- javascript - 对对象数组列表进行排序时的无限循环