tags:

views:

114

answers:

3

hi, I need a regular expression that identify special links.

I have an array with links, for example this one

array[1] = "http://domain.com/dfdf"
array[2] = "http://domain.com/dfgf"
array[3] = "http://domain2.com/derf"

I want to use a regular expression that extract links from this array under a specific domain (for example domain2)

I'll get an array

array[1] = "http://domain2.com/derf"

I'm looking for the pattern only (I use PHP)

A: 

How about:

(?<!")http://domain2.com[^"]+
Al
+2  A: 

This regular expression should do it:

^http://domain2\.com/

And converted into PCRE with / as delimiter:

/^http:\/\/domain2\.com\//

But you can use another character if you want:

~^http://domain2\.com/~
Gumbo
A: 

This will match https as well as http links:

#^https?://domain2\.com/#
Residuum