#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    Got problem : PREG_REPLACE Unkown Modifier


    Hello all, i run this simple cleanup regex pattern and found errror:
    $title="VISIT & JOIN ISIC WORLD";
    $newtitle=preg_replace("[^A-Za-z0-9_-]+","",$title);

    it return error : Unknown modifier '+'

    please help
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Preg_replace requires boundaries on the expression.

    PHP Code:
    $newtitle=preg_replace("/[^A-Za-z0-9_-]+/","",$title); 
    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo