不为空的正则表达式匹配任何非空字符串。这在验证输入时非常有用,例如确保用户输入了密码或电子邮件地址。
| 模式 | 描述 |
|---|---|
| 匹配一个或多个任意字符。 | |
| 匹配零个或多个前一个表达式的重复。 | |
| 匹配不在方括号中的任何字符。 |
| 输入 | 输出 |
|---|---|
false
|
|
true
|
|
"abc"
|
true
|
"123"
|
true
|
"true"
|
true
|
const re = /.+/;const str = "abc";const result = re.test(str);console.log(result); // true
本文地址:https://www.qianwe.com/article/db5eff72aa78b730fccf.html