JSFiddle - React, Tailwind, and code Playground

by thinkingmedia

HTML

<dir id="test"></div>

JavaScript

var str = [
        "Example.com:8080",
        "10.15.123.14:8080",
        "example.com",
        "10.13.123.14",
        "example!1.com:8080",
        "example-1.com:8080",
        "example!1.com:8080",
        "example\1.com:8080",
        "example1.com:8"
        ];
    
    var regex = /^([a-z0-9\-]+\.)+[a-z0-9]+\:[1-9][0-9]+$/i;

    for(var i=0; i < str.length; i++) {
        $('#test').append(regex.test(str[i])+"</br>");
    }