react-native - *%#:& 的正则表达式在本机反应中包括空格?
问题描述
在使用 textBox 做出本机反应时,我需要验证,显示用户是否输入空格或 *%#:& 错误将弹出并突出显示红色文本框。
我的代码 -
_validateInput = (s) => {
let regSpace = new RegExp(/\s/); // what should i add to check *%#:& currently its checking only white space
// Check for white space and (*%#:&)
if (regSpace.test(s)) {
this.setState({ error: true });
return false;
} else {
this.setState({ error: false });
}
return true;
};
解决方案
你可以试试这个
const name = 'Hi my name is john'
name.replace(/*%#:&\s/g, '') //Himynameisjohn
推荐阅读
- python - Python嵌套循环:打印座位
- javascript - SVG 渲染按钮在调整大小的高图上重新定位
- vb.net - Editor.GetEntity 不等待用户输入(点击)
- mysql - MySQL:加载数据本地 INFILE - 命令无法始终如一地工作
- apache - 我们如何在 Jmeter 中处理 recaptcha?
- android - 使用输入对象的graphql突变
- reactjs - 在 React 上运行后台服务
- python - 追加两个for循环django
- java - 字符串到 BigDecimal 值
- python-3.x - 如何配置 serverless.yml 以正确读取 Python 布尔值?