Sort:  

How about

. (-.(-.)*)? (.-.|.)*

Over eager in matching that last character. I should actually put your test cases into a tester before throwing this out there haha... I'll do that next time I swear.

I did it! You weren't far! You just had to delete the first character acceptance in your last .-., since the previous section already ended in letter/number.

^[a-z](-[a-z0-9](-[a-z0-9])*)?(-[a-z0-9]|[a-z0-9])*(?:\.[a-z](-[a-z0-9](-[a-z0-9])*)?(-[a-z0-9]|[a-z0-9])*)*$

Now wondering if it's possible to add a maximum number of characters in this regex.

Working the same way as before.

^[a-z](-[a-z0-9](-[a-z0-9])*)?([a-z0-9]-[a-z0-9]|[a-z0-9])*(?:[a-z](-[a-z0-9](-[a-z0-9])*)?([a-z0-9]-[a-z0-9]|[a-z0-9])*)$

My bad, it actually works better

^[a-z](-[a-z0-9](-[a-z0-9])*)?([a-z0-9]-[a-z0-9]|[a-z0-9])*(?:[a-z](-[a-z0-9](-[a-z0-9])*)?([a-z0-9]-[a-z0-9]|[a-z0-9])*)*$

It's actually working pretty well. I had just missed a period.

but it's still missing a test case.

Further testing:

And more tests:

& more

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.029
BTC 62070.52
ETH 2422.73
USDT 1.00
SBD 2.64