SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    $content = ereg_replace("<a href=\"dmoz.php3?/\">Top</a>", "<a href=\"http://www.westbranch.net\">Home</a>", $content);
    Okay I can't print my code like I'd like too... but anyways there is that statement. Now imagine it with all the \'s before all the "'s like it should be (I can't include them because VB still parses them)

    So when you add in the appropratie \'s right where the red is it looks like: /\_" without the _ (I'm talking the code - not the end result - the replace doesn't work so content looks the same before and after)


    And I think that is where the problem is, because this statement isn't replacing like it should.
    Last edited by aspen; Feb 16, 2001 at 14:36.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm a little bit confused here - can you show us the value of $content beforehand, and then afterwards, directly copied/pasted?

  3. #3
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm working on a script that takes and parses DMOZ info. $content is a dmoz webpage.

    Besides like I said it looks the same before and after - the replace isn't working.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  4. #4
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ereg_replace is working! But there are something with your code
    Try:

    $pat = '<a href="dmoz.php3?/">Top</a>';
    $pat2 = '<a href="http://www.westbranch.net">Home</a>';
    $content = ereg_replace($pat,$pat2,$content);

    Also, str_replace would be a better choice if this's all you need.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  5. #5
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that didn't work. But simply switching ereg_replace to str_replace did work....
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  6. #6
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's a good point - ereg/eregi_replace are only to be used if a regular expression is involved. Sort of like split() and explode()

  7. #7
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Weird, since Reg. Exp is much more than just comparing strings, so string comparing is included in RE, probably some chars were misunderstood as RE meta-symbols by the engine, like "?"
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  8. #8
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this

    $content = ereg_replace("<a href=\"dmoz.php3?/\">Top</a>", "<a href=\"http://www.westbranch.net\">Home</a>", $content);

    that should work and im so clever if it doesnt work then im just dumb
    Need a CGI Script ?? checkout CGI-Scripting

  9. #9
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Graeme thats exactly what I was doing and it wasn't working...

    VB was parsing the \" in my post though so I didn't post it like that.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •