Forum Moderators: coopster
$MyReplaceStr = "多ttp://([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/x(.*)&" . $MySite . "各i";
$GetPage = preg_replace(
$MyReplaceStr,
$MySite."/site/".$site,
$GetPage
);
I need also to be able to remove the "多ttp://([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/x(.*)&" part from the remaining external links (the ones without $MySite which is just my www.mysite.com domain) that have it. How would I add that onto the script and to avoid conflict how would I exclude the other one within that? I'm sure someone understands.
[edited by: Cyrus255 at 9:48 am (utc) on Nov. 8, 2006]
I didn't think it was that complicated... I just don't know hardly any code...
I just want to add onto or modify this script which currently changes internal links that have the $MySite variable (my domain name) to also remove the "http://([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/generatedcode(.*)&" part from external links as well
Here's the code:
$GetPage = preg_replace(
"多ttp://([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/generatedcode(.*)&" . $MySite . "各i",
$MySite."/site/".$site,
$GetPage
);
Basically I just want to remove the "多ttp://([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/generatedcode(.*)&" part for external links on these generated pages, that don't have $MySite in them (which is just my domain name), in ADDITION to the above code which changes some internal linking structures.
It's really simpler than it sounds. Thanks in advance for any help.
[edited by: Cyrus255 at 7:54 pm (utc) on Nov. 9, 2006]
It's a little hard to understand what you are asking for. Maybe some sample input/output will enable us to help a little better (remember to generalize your urls).
$GetPage = preg_replace(
"多ttp://([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/generatedcode(.*)&" . $MySite . "各i",
$MySite."/archive/".$site,
$GetPage
);
The above code changes all the internal links in the $GetPage (this is within a cURL generated page) that have basically a "http://123.123.123./generatedcode(.*)&=" sequence to remove that part, and then adds on /archives/filename.html
from
[123.123.123....]
to
[mysite.com...]
But I want it to ALSO change external links IN those archive files to not have the 123.123.123 part either, so changing from
[123.123.123....]
to their original form
[othersite.com...]
Basically I've tried something LIKE this (but not this) trying to replicate the same code, but without the $MySite variable.
$GetPage = preg_replace(
"多ttp://([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/generatedcode(.*)&",
" " <---- (how do I write to replace it with nothing? and it has to be added onto the original code or not conflict with the code that changes the internals to " $MySite."/site/".$site" as well)
$GetPage
);
Thanks again. Simpler than it sounds but I'm a real PHP newbie.
[edited by: Cyrus255 at 6:31 am (utc) on Nov. 11, 2006]
Few questions (maybe it's easier than yuo think)
1. Is this the first =, that you are refering to?
2. Will there always be http after? =http...
3. Do you want to limit it from the end somehow?
if true, true, false, then
$Page = "http://123.123.123./generatedcode(.*)&=http://www.mysite.com/hello";
$Mypage = "http" . substr($Page, strpos($Page, "=http"), strlen($Page));
now in Mypage you have
[mysite.com...]
Is that what you wanted?
PS. Sometimes working on a string is easier than you think
Regards
Michal