Link Posted June 16, 2007 Share Posted June 16, 2007 For some reason, when it does the preg_match() it doesn't pick up the last . after p.m. ...why? <?php $str = "Meeting with Bryan and Co. June 10th from 8:00 a.m. to 9:00 p.m."; if (preg_match("/\b(from)?\s*([0-9]{1,2}:[0-9]{2})\s*(a\.?m\.?|p\.?m\.?)?\s*(to)\s*([0-9]{1,2}:[0-9]{2})\s*(a\.?m\.?|p\.?m\.?)?\b/", $str, $matches)) { print $matches[0]; $str = preg_replace("/\s*".$matches[0]."\s*/", " ", $str); } ?> Which outputs: from 8:00 a.m. to 9:00 p.m What happened to the trailing .? Quote Link to comment https://forums.phpfreaks.com/topic/55860-preg_match-problem/ 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.