Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 如何仅匹配不包含特殊字符的字符串(使用正则表达式)_Regex - Fatal编程技术网

Regex 如何仅匹配不包含特殊字符的字符串(使用正则表达式)

Regex 如何仅匹配不包含特殊字符的字符串(使用正则表达式),regex,Regex,我试图找到一个只匹配字符串的regexp,如果字符串不包含@或空或http:或https: e、 g.它与stackoverflow、42abc47或a-bc-31_4匹配,但不匹配: swp@aa, '', https:stackoverflow or http:test. 我试图想出这个/^[a-z,.-]+$/I 这行吗 谢谢 这可能对你有帮助 /^http(s)?:\/\/(www\.)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]

我试图找到一个只匹配字符串的regexp,如果字符串不包含
@或空或http:或https:
e、 g.它与stackoverflow、42abc47或a-bc-31_4匹配,但不匹配:

swp@aa, '', https:stackoverflow or http:test.
我试图想出这个
/^[a-z,.-]+$/I
这行吗

谢谢

这可能对你有帮助

/^http(s)?:\/\/(www\.)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/.test('www.google.com')