Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Validate Tutorialspoint URL via JavaScript regex?
To validate a specific URL, use regular expression.
Example
The code is as follows −
function validateSoundURL(myURL) {
var regularExpression = /^https?:\/\/(tutorialspoint\.com)\/(.*)$/;
return myURL.match(regularExpression) && myURL.match(regularExpression)[2]
}
console.log(validateSoundURL("https://tutorialspoint.com/index"));
console.log(validateSoundURL("https://tutorialspoint.com/java"));
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo259.js.
Output
This will produce the following output on console −
PS C:\Users\Amit\javascript-code> node demo259.js index java
Advertisements
