通过JavaScript正则表达式验证Tutorialspoint URL?
要验证特定的URL,请使用正则表达式。
示例
代码如下-
function validateSoundURL(myURL) {
var regularExpression = /^https?:\/\/(nhooo\.com)\/(.*)$/;
return myURL.match(regularExpression) && myURL.match(regularExpression)[2]
}
console.log(validateSoundURL("https://nhooo.com/index"));
console.log(validateSoundURL("https://nhooo.com/java"));要运行上述程序,您需要使用以下命令-
node fileName.js.
在这里,我的文件名为demo259.js。
输出结果
这将在控制台上产生以下输出-
PS C:\Users\Amit\javascript-code> node demo259.js index java
热门推荐
10 生日祝福语朋友简短的话
11 宝贝的人生祝福语简短
12 新年有哪些祝福语简短
13 简短又洋气祝福语大全
14 简短祝福语除夕快乐英文
15 生日贺卡祝福语毕业简短
16 战友聚会祝福语幽默简短
17 最新中秋祝福语简短英语
18 夏日升学宴祝福语简短