PHP - Moved: Preg_match A Number With <b> Tags
This topic has been moved to PHP Regex.
http://www.phpfreaks.com/forums/index.php?topic=345873.0 Similar TutorialsI want to validate a form field for a number with two decimals (ie. 894567.29), but my script gives me an error, asking me to correct the entry, Following is a snippet of the script:- elseif($field == "oil_waste_ltr") { if(!preg_match("/^[0-9]{1,10}\.{2}$/",$value) ) { $bad_format[] = $field; } } This is my preg_match code:
preg_match("/(\d+)|(T)|(A)/", $link, $matches, PREG_OFFSET_CAPTURE, ($off-30)
It works and matches the number I want, except it only returns the first character in the $matches array. For instance, if the number it finds is 10, it only returns 1. Now I understand that is what preg_match does, but how would I make that regex ungreedy? I tried adding a *, but it just made an error, and preg match all would keep searching for strings after the first one. All I want is for the first number, regardless of the length of it, to be returned in full. Thanks for any help.
This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=331694.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=355835.0 This topic has been... uh... whatsit... moved? to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=353911.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=323604.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=320132.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=318181.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=314652.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=329803.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=357263.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=318058.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=329322.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=317682.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=348975.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=317962.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=345218.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=315924.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=327702.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=320413.0 |