vendredi 11 septembre 2015

Make regex betterer

I need an expression that covers two eventualities:

www.example.com
knowledge.example.com

There are many other possible subdomains so it needs to be specifically either the root domain or the knowledge domain.

I did have a go and this appears to work. But it looks long and unsightly and I wondered if there was a more elegant regex:

(www\.)?(knowledge\.)?(example\.com)

It's not that long and ugly, I suppose. I'm just curious if I'm approaching it right or if there's a shorter way of writing it.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire