Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Ezilon Directory   Improve your ranking, submit to directories   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 06-17-2007, 07:12 PM   #1 (permalink)
Contributing Member
 
Join Date: 02-17-06
Location: Sacramento, California
Posts: 226
iTrader: 0 / 0%
Latest Blog:
Far better?

pairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nice
Send a message via Yahoo to pairbrother
preg replace - replace links

Hi there,

I have a a large number of pages in which I want to replace parts of links within it. Ill give an example
This is the html I am getting from a function:
Code:
<p>In most <a href=\"/toreplace/Bird\" title=\"Bird\">birds</a> and <a href=\"/toreplace/Reptile\" title=\"Reptile\">reptiles</a>, an <b>egg</b> is the <a href=\"/toreplace/Zygote\" title=\"Zygote\">zygote</a>, resulting from <a href=\"/toreplace/Fertilization\" title=\"Fertilization\">fertilization</a> of the <a href=\"/toreplace/Ovum\" title=\"Ovum\">ovum</a>. It nourishes and protects the <a href=\"/toreplace/Embryo\" title=\"Embryo\">embryo</a>.
I want to replace all the links in it for ex:
Code:
<a href=\"/toreplace/Bird\" title=\"Bird\">birds</a>
with
Code:
<a href=\"/Bird.html\" title=\"Bird\">birds</a>
That is I want to remove the text "toreplace" and add a .html at the end of the link.

I hope this is possible using php regex and I am at the right place amongst the right people.
Any help would be appreciated. Thanks a lot
__________________
pairbrother is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 06-18-2007, 09:57 AM   #2 (permalink)
Contributing Member
 
Join Date: 02-17-06
Location: Sacramento, California
Posts: 226
iTrader: 0 / 0%
Latest Blog:
Far better?

pairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nice
Send a message via Yahoo to pairbrother
i got that. Thanks for looking
__________________
pairbrother is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-18-2007, 10:28 AM   #3 (permalink)
Empress™
 
chicgeek's Avatar
 
Join Date: 08-19-04
Location: York, UK
Posts: 17,965
iTrader: 0 / 0%
Latest Blog:
My Favourite Poem

chicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest order
Good stuffs.
__________________
laura / chicgeek
soprano & web designer
laurakishimoto.ca
chıcgeeĸ @ flickr
chicgeek is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-18-2007, 11:34 AM   #4 (permalink)
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 2,960
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
hi, pairbrother!

When you log back in, please share your solution to the problem! Let us know how you do it!
I'm sure that will be helpful for other members in the future.

Cheers!
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-19-2007, 12:19 PM   #5 (permalink)
Contributing Member
 
Join Date: 02-17-06
Location: Sacramento, California
Posts: 226
iTrader: 0 / 0%
Latest Blog:
Far better?

pairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nicepairbrother is just really nice
Send a message via Yahoo to pairbrother
since nobody replied, i thought nobody knows how to do it..or they r just too busy to look at this
Anyways krt from dp helped me:

Code:
preg_replace('~href="/toreplace/([^"]+)"~', 'href="/$1.html"', $html);
__________________
pairbrother is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to replace 100's of links all at once Johnny0123 Web Design Lobby 11 05-16-2007 01:24 AM
need help w/ find and replace script... PhoenixSlayerSX Coding Forum 0 01-07-2007 11:48 AM
Should SEM replace SEO? webmaster SEO Forum 19 02-07-2006 07:44 PM
Global Replace in Dreamweaver? Buskerdoo Coding Forum 8 02-17-2005 09:04 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 09:47 PM.
© Copyright 2008 V7 Inc