www.webdeveloper.com
Results 1 to 6 of 6

Thread: Need help with function.preg-replace

  1. #1
    Join Date
    Sep 2012
    Location
    Oklahoma
    Posts
    5

    Need help with function.preg-replace

    This is what I am getting in the error log

    No one can post to the forum or blog on my site

    PHP Warning: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Compilation failed: nothing to repeat at offset 1 in /home/lbbc2012/public_html/internals/Apps/TextService.app.php on line 316

  2. #2
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    Well?

    What's the preg_replace() on line 316 of /home/lbbc2012/public_html/internals/Apps/TextService.app.php?

  3. #3
    Join Date
    Sep 2012
    Location
    Oklahoma
    Posts
    5
    {
    switch( $badword['type'] )
    {
    case 'word' :
    $badword['badword'] = str_replace( '\*', '[\w~@\#$%^&*()_+|]*', preg_quote($badword['badword']) );
    //$this->search_array[] = '#(^'.$badword.'(?=\s|$))|((?<=\s)'.$badword.'(?=\s|[.;:,?!]|$))#i';
    $this->search_array[] = '#(\b'.$badword['badword'].'\b)#i';
    break;
    case 'string' :
    $badword['badword'] = str_replace( '\*', '[\w~@\#$%^&*()_+|]*', preg_quote($badword['badword']) );
    $this->search_array[] = '#('.$badword['badword'].')#i';
    break;
    case 'regexp' :
    $this->search_array[] = '#('.$badword['badword'].')#i';
    break;
    }
    }



    right before the last break

  4. #4
    Join Date
    Sep 2012
    Location
    Oklahoma
    Posts
    5
    Warning: prge_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 1 in /home/lbbc2012/public_html/internals/Apps/TextSevice.app.php on line 316
    {exec: new function(“window.location.href = \”https: \\\/\\\/www.lbbclub.com\\\/forum\\\/topic.php?topic_id=8\”;\n”), data: null}

  5. #5
    Join Date
    Sep 2012
    Location
    Oklahoma
    Posts
    5
    {
    switch( $badword['type'] )
    {
    case 'word' :
    $badword['badword'] = str_replace( '\*', '[\w~@\#$%^&*()_+|]*', preg_quote($badword['badword']) );
    //$this->search_array[] = '#(^'.$badword.'(?=\s|$))|((?<=\s)'.$badword.'(?=\s|[.;:,?!]|$))#i';
    $this->search_array[] = '#(\b'.$badword['badword'].'\b)#i';
    break;
    case 'string' :
    $badword['badword'] = str_replace( '\*', '[\w~@\#$%^&*()_+|]*', preg_quote($badword['badword']) );
    $this->search_array[] = '#('.$badword['badword'].')#i';
    break;
    case 'regexp' :
    $this->search_array[] = '#('.$badword['badword'].')#i';
    break;
    }
    }

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,222
    I did not go over everything carefully, in part because it's difficult to read code snippets if you do not wrap them in the forum's [php]...[/php] bbcode tags. One thing I noticed though is that if you are going to use preg_quote(), you should use the optional 2nd parameter to specify the regexp delimiter you plan on using (in this case apparently the "#").
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles