Last active
July 25, 2021 09:10
-
-
Save MentalGear/d718c93b9bb0f4f47d10c7a52b7c5832 to your computer and use it in GitHub Desktop.
Regex: Get URL Network Protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based upon: | |
// https://docs.microsoft.com/en-us/dotnet/standard/base-types/how-to-extract-a-protocol-and-port-number-from-a-url | |
const url = 'http://www.google.com/fwef://gerg'; | |
const regex = /^(?<proto>\w+):/g; | |
const found = url.match(regex); | |
console.log(found); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment