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 Link to comment https://forums.phpfreaks.com/topic/214433-regular-expression-for-4-digit-number-with-two-decimal-places/ 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) Link to comment https://forums.phpfreaks.com/topic/214433-regular-expression-for-4-digit-number-with-two-decimal-places/#findComment-1115862 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 Link to comment https://forums.phpfreaks.com/topic/214433-regular-expression-for-4-digit-number-with-two-decimal-places/#findComment-1115877 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? Link to comment https://forums.phpfreaks.com/topic/214433-regular-expression-for-4-digit-number-with-two-decimal-places/#findComment-1115887 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 Link to comment https://forums.phpfreaks.com/topic/214433-regular-expression-for-4-digit-number-with-two-decimal-places/#findComment-1115893 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) Link to comment https://forums.phpfreaks.com/topic/214433-regular-expression-for-4-digit-number-with-two-decimal-places/#findComment-1115894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.