URL Regex

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

Moderator: General Moderators

Post Reply
sjeakins
Forum Newbie
Posts: 2
Joined: Mon Nov 19, 2007 10:13 am

URL Regex

Post by sjeakins »

Hi Folks,

Is there any way to capture the URL from this text using only one regex expression?

<td><span class="proxy77602">202</span>.<span class="proxy77602">115</span>.130.23:
8080</td>

TIA,

Sandy Jeakins
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

What URL?
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Jcart wrote:What URL?
Thats what i thought, but there is an IP.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Zoxive wrote:
Jcart wrote:What URL?
Thats what i thought, but there is an IP.
Mashed in the middle of a bunch of HTML. Honestly, I'd do a strip_tags() type thing, then massage from there, if necessary.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

/>([0-9\.:]+)/m
Will match your specific example. Most likely you will need to tweak it to suit your needs.
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Post by GeertDD »

Jcart wrote:

Code: Select all

/>([0-9\.:]+)/m
No need to escape metacharacters inside a character class.

Code: Select all

/>([0-9.:]+)/m
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Woohoo! Good to know :)
sjeakins
Forum Newbie
Posts: 2
Joined: Mon Nov 19, 2007 10:13 am

Post by sjeakins »

Yes, sorry - IP.
Post Reply