Thread: regex help?

    #1
  1. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    The code below strips out eg, [<a href etc...</a>] (the square brackets are part of the string) - but when there is more than one occurance of the [<a....>/] code the ereg_replace only works once , starting with the first [<a and ending with the last a>] missing all the other occurences in the middle. the code;

    $boo= eregi_replace( "[<A(.*)A>]", " ", $plain );

    If the string to stip was always the same I would use str_replace() ,but it is not although it will always start with [<a and end with a>].

    Any links on tutorials/explanations of regex would be appreciated - I have read the manual but obviously I am not quite getting it.

    Help appreciated,

    Simon Wheeler.


    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    12
    Rep Power
    0
    Try
    $boo=eregi_replace("[<A[^]]*A>]","",$plain);

    (Not tested.)

    Also:
    Search for "regex" and/or "posix" in the forums at http://phpbuilder.com/ (when the site starts responding again).

Similar Threads

  1. regex to strip C comments?
    By pattonme in forum Perl Programming
    Replies: 3
    Last Post: January 1st, 2004, 11:37 PM
  2. compile php to use system regex and apache2
    By edman007 in forum PHP Development
    Replies: 0
    Last Post: November 7th, 2003, 08:11 PM
  3. Need help on regex?
    By trendmatrix in forum HTML Programming
    Replies: 1
    Last Post: August 2nd, 2003, 05:54 PM
  4. Replies: 1
    Last Post: October 30th, 2001, 12:42 PM
  5. which regex approach is best
    By bumperbox in forum Perl Programming
    Replies: 3
    Last Post: August 30th, 2001, 06:05 PM

IMN logo majestic logo threadwatch logo seochat tools logo