Regular Expressions 101

Community Patterns

get top level domain excluding ports

1

Regular Expression
ECMAScript (JavaScript)

/
([\w][\w\d-]+\.[\w\d]{2,3})$
/
gmi

Description

I need to get the top level domain from the request header but it can be in a vary ways.. how can I match but exclude parts I dont want to get ie. ports

Submitted by nei - 9 years ago