[英]Regex creation for JS validation
I'm having some trouble creating the proper regex to validate input. 我在创建适当的正则表达式以验证输入时遇到麻烦。 I feel it is pretty simple to do but am still having a couple issues.
我觉得这很简单,但是仍然有一些问题。
the ideal input would be as follows without the quotes: "tests.xxxxxxx" with the x's being replaced with any alphanumeric character. 理想的输入如下,不带引号:x替换为任何字母数字字符的“ tests.xxxxxxx”。 the only non-alphanumeric character is the period that separates 'tests' from the second half of the string.
唯一的非字母数字字符是将“测试”与字符串的后半部分分开的句点。
(tests\.){1}
You can use the following regex with test()
to validate: 您可以将以下正则表达式与
test()
以进行验证:
tests\.[a-zA-Z0-9]+
Edit: If you want to restrict only one tests
you can use a lookahead: 编辑:如果只想限制一个
tests
,则可以使用前瞻:
tests\.(?!.*tests)[a-zA-Z0-9]+
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.