SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2007
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Matching "*" using preg_match. Please help.

    HI,

    I need to search for "*" in $value. The below code is not matching. Please help.

    Code:
    		if(preg_match('/(*)/i',$value))
    		{
    			$fields.="";
    			echo "* is selected<br>";
            }
    Thanks,
    Ramki

  2. #2
    SitePoint Member picsmafia's Avatar
    Join Date
    Dec 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't use regular expressions to test if a simple string is contained in another string
    PHP Code:
    if(false !== strpos($value'*')) {
       echo 
    "* is selected<br>";

    Also, there's no point appending an empty string to $fields, it changes nothing.


Bookmarks

Posting Permissions

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