|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
PCRE--match that don't have http://, https://, or ftp://
i have been working on this for hours and have looked everywhere, i just can figure out how do i match the urls in the <a > tags in some html if it doesn't have an http of ftp protocol
i want it to match things like this <a href="list.php"> <a href="httpphp.php"> but not this <a href="http://site.com" > here is what i got so far Code:
preg_match('/<a(.*?)href(\s)*=(\s)*(\'|")*(http:\/\/|https:\/\/|ftp:\/\/){0}(.*?)(\'|")*(.*?)>/i',$html);
but this will match all examples i put above EDIT::: fixed the escape charcters Last edited by edman007 : December 13th, 2003 at 09:56 PM. |
|
#2
|
||||
|
||||
|
the php code tags strip the slashes form it, you have to use the [code] tags.
do this instead PHP Code:
|
|
#3
|
|||
|
|||
|
<a href="ftp-servers.html" />
|
|
#4
|
||||
|
||||
|
i don't think i can do that, i am editing all the <a href="blah" > tags in an html page and i'm going to use preg_replace() (unless there is an easier way), and have to do different things if it doesn't have the protocol, also i want it to match blah.php?http://blah i only want it to not match it if it is the first part of the url
|
|
#5
|
||||
|
||||
|
so dose anyone know how to do this?
|
|
#6
|
|||
|
|||
|
Hi
If your wanting to match all of these then why not use preg_match_all, it will give you more control.... Example..... PHP Code:
You can refine the preg_match_all, I just did it quick for the example! F! |
|
#7
|
||||
|
||||
|
i want to match just the ones that don't start with ftp://, http:// or https:// so it can be used in preg_replace(); i don't know how i would use preg_match_all to do this
here is what i am using, now, i just have to get the match part right PHP Code:
edit---had to escape the escape things Last edited by edman007 : December 14th, 2003 at 10:30 AM. |
|
#8
|
|||
|
|||
|
Hi
Did you try my example? F! |
|
#9
|
||||
|
||||
|
i'm just getting an empty array
i want it to replace as i showed above, i can't get it to do that with what you gave me |
|
#10
|
|||
|
|||
|
Hi
Look at view source, not the browser output! F! |
|
#11
|
||||
|
||||
|
|
|
#12
|
||||
|
||||
|
i did a print_R of both $matches and $links and here is what i get
Code:
Array
(
[0] => Array
(
)
[1] => Array
(
)
[2] => Array
(
)
[3] => Array
(
)
[4] => Array
(
)
[5] => Array
(
)
[6] => Array
(
)
[7] => Array
(
)
[8] => Array
(
)
)
Array
(
)
there is nothing there and nothing that can point me in the right direction on what to change |
|
#13
|
|
|
|