ereg_replace -->REG_BADRPT warning

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tmcp
    New Member
    • Oct 2006
    • 1

    #1

    ereg_replace -->REG_BADRPT warning

    Hello I'm a bit new to regular expressions and I'm having a problem

    I'm trying to strip any code which is inside a <p> tag for instance from
    <p style="margin: 0in 0in 0pt;" class="MsoNorma l">
    to
    <p>

    I'm using the following line where $tmpString is the string of html pasted from word.

    $tmpString = ereg_replace("< p.*?>", "<p>", $tmpString);

    when I use this code I get the error
    <b>Warning</b>: ereg_replace(): REG_BADRPT

    I've used http://regexlib.com/RETester.aspx tool to see if the <p.*?> is working properly and it seems to be.

    I tried replacing it with
    preg_replace("< p.*?>", "<p>", $tmpString);
    but this didn't work either it seems just replace every "p" with <p>

    Any help much appreaciated.
  • sujithfem
    New Member
    • Jun 2006
    • 3

    #2
    Hi I have found the solution , the issue due to special character esp for this warning REG_BADRPT error , use backslashing before any special chars in your pattern string.

    For example:


    $source = eregi_replace(" \*", "", $invar)

    Comment

    Working...