简体   繁体   English

在javascript中使用服务器端正则表达式

[英]using serverside regular expression in javascript

I am validating website by writing serverside regular expression when i copy the same 我正在通过编写服务器端正则表达式验证网站,当我复制它时
thing in javascript and try to validate its not happening a part of my code is as follows 的东西,并尝试验证其没有发生我的代码的一部分如下

"^(https://)+\w+\.+\w" - //serverside validation working fine
document.getElementById('txtWebsite').value.match("^(https://)+\w+\.+\w") == null

how can i implement the same in client side validation 我如何在客户端验证中实现相同的功能

String.match is considering you regex as String and not as a RegExp object. String.match考虑将正则表达式视为String而不是RegExp对象。 Try this: 尝试这个:

document.getElementById('txtWebsite').value.match(/^(https:\/\/)+\w+\.+\w/)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM