On Wednesday 07 February 2001 21:48, Jason Bryner wrote:
> I'm making a small script that imports HTML pages and I need to do
> some string replacement. I need to replace add a url to all the 'HREF'
> links and images, but if someone could just give me an example of how
> to replace and append the HREF part, I think I can figure it out. It
> needs to find all the variations of HREF, such as 'HREF = "', href="',
> 'href =', etc. So it
> needs to be space and capitalization carefree. THANKS TO ANYONE
> WHO HELPS!!!
$replaced = preg_replace ('/(href\s*=\s*(\'|\"))(.*?)(\\2)/i',
"\\1\\3${urladdition}\\2",
$matches);
On a match, $matches [0] will contain the entire pattern, $matches [1]
the first subpattern (everything from href to the opening quote),
$matches [2] the opening quote char and $matches [3] the URL.
--
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)
"These are the people who proudly call themselves "hackers" --
not as the term is now abused by journalists to mean a computer
criminal, but in its true and original sense of an enthusiast,
an artist, a tinkerer, a problem solver, an expert."
- ESR
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]