Created
September 9, 2018 12:40
-
-
Save bgauryy/5320065aa9c4195239eb0b1474649ebb to your computer and use it in GitHub Desktop.
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
| const IPV4Reg = '((([0-9])|(1*[0-9][0-9])|(2[1-4][0-9])|(25[0-5]))\\.){3}(([0-9])|(1*[0-9][0-9])|(2[1-4][0-9])|(25[0-5]))'; | |
| const IP4 = `(^${IPV4Reg}$)|(^${IPV4Reg}\\:)|(^${IPV4Reg}\/)`; | |
| function getIPDomain(url) { | |
| const matches = new RegExp(IP4).exec(url); | |
| if (matches && matches[0]) { | |
| return matches[0].replace(/\:|\//, ''); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment