#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    2
    Rep Power
    0
    Hello

    *All* I want to do, and it's driving me nuts, is to remove everything in a string that appears between <e> and </e>. Anything at all can appear between those two tags and they may appear more than once in the string but always in that order. "<e>.*<e>" takes out everything of course, i.e. :

    <e>blahblah</e> 123456 <e>booboo</e>

    removes the whole lot rather than leaving the 123456...

    Inspiration, assistance and even a solution are greatly appreciated

    Christopher

    Comments on this post

    • Gran Roguismo agrees
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    Annapolis, Maryland US
    Posts
    113
    Rep Power
    16
    <?
    $code="<e>blahblah</e> 123456 <e>booboo</e>";
    $sections=split("<[/]?e>", $code);

    //now the indeces of the $sections array contain 'blahblah', ' 123456 ', and 'booboo', respectively

    ?>

    Comments on this post

    • Gran Roguismo agrees
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    Annapolis, Maryland US
    Posts
    113
    Rep Power
    16
    Sorry, I didn't pay attention to the question...

    To remove it, try something like

    <?

    $var="blahblah<e>123456</e>booboo";

    $var=ereg_replace("<e>[a-zA-Z0-9<>/]{1,}</e>", "", $var);

    print"$var<br>";

    ?>

    This will replace most HTML tag elements -> to blow away other stuff like asterisks, the @ sign, etc. just mess around with the regex a bit

    if $var="<e>blahblah</e> 123456 <e>booboo</e>";

    you will be left with ' 123456 '

    [This message has been edited by Kyuzo (edited January 27, 2000).]

Similar Threads

  1. regex in php
    By MartijnMegens in forum PHP Development
    Replies: 5
    Last Post: February 13th, 2004, 04:02 AM
  2. Replies: 5
    Last Post: February 11th, 2004, 03:18 AM
  3. Replies: 0
    Last Post: February 11th, 2004, 12:44 AM
  4. javascript inside php tags
    By andy123 in forum JavaScript Development
    Replies: 5
    Last Post: February 5th, 2004, 05:34 PM
  5. Replies: 0
    Last Post: January 18th, 2004, 08:53 AM

IMN logo majestic logo threadwatch logo seochat tools logo