Jump to content


Photo

Preg_Replace pattern problems


  • Please log in to reply
2 replies to this topic

#1 jfee1212

jfee1212
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 09 May 2006 - 08:17 PM

I am making a simple PHP proxy script to allow access to sites blocked by my school's firewall.

I am trying to change all relative links to absolute links so they are consistant and easier to work with.

I have this code...

$pattern = '#href[\s]*\=[\s]*(\'|"|)(\|/|)#i';
$replace = 'href="'.$_POST['site']."/";
$html = preg_replace($pattern, $replace, $html);
}

However when I open google with this done, the links are still relative.

Any assistance in correcting and understanding the problem is greatly appreciated.

TIA
-Josh

#2 jfee1212

jfee1212
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 23 May 2006 - 11:47 AM

bump...


#3 samshel

samshel
  • Members
  • PipPipPip
  • Advanced Member
  • 837 posts

Posted 23 May 2006 - 12:12 PM

$pattern = '#href[\s]*\=[\s]*(\'|"|)(\|/|)#i';
$replace = 'href=$1'.$_POST['site'].'/';
$html = preg_replace($pattern, $replace, $html);
}

Cheers,
SamShel
-----------------------------------------------
--: FUTURE IS LINUX :--
-----------------------------------------------




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users