
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
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
- Related Articles
- How to validate URL address in JavaScript?
- Validate URL in ReactJS
- Validate IPv4 address using ReGex patterns in C++
- Validate IPv6 address using ReGex patterns in C++
- Passing parameter with parenthesis via URL in SAP Open document
- How to validate a URL using regular expression in C#?
- Construct string via recursion JavaScript
- How do you validate a URL with a regular expression in Python?
- How to validate given date formats like MM-DD-YYYY using regex in java?
- JavaScript - Redirect a URL
- Print pyramid of tutorialspoint in PL/SQL
- Replace commas with JavaScript Regex?
- Obtaining maximum number via rotating digits in JavaScript
- How to validate decimal numbers in JavaScript?
- How to validate email address in JavaScript?

Advertisements