Regex for links

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Regex for links

Post by klevis miho »

I have this regex:
'#(([a-zA-Z0-9-]+)\.)*([a-zA-Z0-9-]+)\.([a-zA-Z0-9-]+)#'

which is good, except that it doesn't get links with a directory behind like:
domain.com/directory

How to solve this?
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: Regex for links

Post by DigitalMind »

try '#(([a-zA-Z0-9-]+)\.)*([a-zA-Z0-9-]+)\.([a-zA-Z0-9-]+)(/[a-zA-Z0-9-]+)*#'
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: Regex for links

Post by klevis miho »

Thanx
Post Reply