Regex that somewhat validates if a value has one of the following characteristics:
123-29-123-123.subdomain.zomg.com:8085
123.12.34.56:420
Unfortunately, I'm terrible at Regex, C#, google searches, and the differences between proper nouns and regular ones.
It can be a lose approximation, in fact I would go with anything that has a : colon separator with a port after it.
Will this work?
^(?<Host>[^:]+)(?::(?<Port>\d+))?$
This gives me:
Host = 123-29-123-123.subdomain.zomg.com Port = 8085
and
Host = 123.12.34.56:420 Port = 420
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With