Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts

    eregi_replace pattern

    I'm trying to change a body tag from a string of html from whatever it is to <body>.

    I tried:
    PHP Code:
    $dataHtml eregi_replace("'<body[^>]*?>',","<body>",$dataHtml); 
    Any help would be appreciated.

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    I'm a bit confused about what you're trying to do here. isnt <body> a body tag?
    What exactly are you trying to accomplish?

  • #3
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    PHP Code:
    $dataHtml preg_replace('/<body[^>]*>/''<body>'$dataHtml); 
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #4
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    only change I'd suggest is to make it case insensitive:
    Code:
    $dataHtml = preg_replace('/<body[^>]*>/i', '<body>', $dataHtml);


  •  

    Posting Permissions

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