rahulag38 Posted September 26, 2010 Share Posted September 26, 2010 Hello, I need the regular expression for xxxx.xx . The code i am using is showing error. My code: $pattern='^\d{1,4}(\.\d{1,2})?$'; preg_match_all($pattern, $stringss, $matches); The error i am getting: Warning: preg_match_all() [function.preg-match-all]: No ending delimiter '^' found in /home/flightde/public_html/test.php on line 3 Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 26, 2010 Share Posted September 26, 2010 $pattern='/^\d{1,4}(\.\d{1,2})?$/'; (don't forget your / delimiters) Quote Link to comment Share on other sites More sharing options...
rahulag38 Posted September 26, 2010 Author Share Posted September 26, 2010 $pattern='/^\d{1,4}(\.\d{1,2})?$/'; (don't forget your / delimiters) Thanxs a lot.. Also what would be the reg ex for - 1. "[2] = xxxx.xx" 2."[2]=xxxx.xx" i.e everything between the quotes " " including the square brackets ,"=" sign and the digit "2", where X = number between 0-9. The diff btw first and second is that spaces are eliminated Quote Link to comment Share on other sites More sharing options...
daydreamer Posted September 26, 2010 Share Posted September 26, 2010 \[\d\]\s?=\s?\d{1,4}\.\d{1,2}\s? Quote Link to comment Share on other sites More sharing options...
rahulag38 Posted September 26, 2010 Author Share Posted September 26, 2010 \[\d\]\s?=\s?\d{1,4}\.\d{1,2}\s? Thanxs a lot for replying.. The digit in the square bracket has to be "2" and not just ant digit . Also could not understand why have you used "?" . I want the exact pattern match and nothing optional Quote Link to comment Share on other sites More sharing options...
rahulag38 Posted September 26, 2010 Author Share Posted September 26, 2010 \[\d\]\s?=\s?\d{1,4}\.\d{1,2}\s? Thanxs a lot for replying.. The digit in the square bracket has to be "2" and not just ant digit . Also could not understand why have you used "?" . I want the exact pattern match and nothing optional And the pattern would be : "[2] = 'xxxx.xx'" Every thing between double quotes (including the single quote surrounding the digits) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.