Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
^(?:https?:\/\/)?([a-zA-Z0-9\.\-_]+)(?:[\/.\-_a-zA-Z0-9]*)$
/

Description

Will return domain portion of a url: Example: http://www.jkrowlings.com/books

Returns: www.jkrowlings.com

Submitted by Scott Burrows - 9 years ago