port-regex 
Regular expression for matching ports
Install
$ npm install --save port-regex
Usage
const portRegex = require('port-regex');
portRegex().test('http://github.com:80');
portRegex().test('127:0.0.1:3000');
portRegex({exact: true}).test('http://github.com:80');
portRegex({exact: true}).test(':3000');
'http://github.com:80 127:0.0.1:3000'.match(portRegex());
API
portRegex([options])
exact
Type: boolean
Default: false
Only match an exact string. Useful with RegExp#test to check if a string is a port.
License
MIT © Kevin Martensson