LostOblivion Posted August 21, 2006 Share Posted August 21, 2006 Hey. First time post here I think. I'm making this calendar and I'm trying to parse a time format from an input field - when I suddenly hit a wall.What I'm trying to do here is to get the hours and minutes off of a string such as2:5002:502 5002 502.5002.502500250202All of the above can be entered by the user and I've come up with a regex I think works to do this job. (All of the above can be read as 2 hours and 50 minutes by a human right? (Except for the bottom two which are 2 hours.) And I'm sure this regex works since I've tested it with ereg.)[code]$regex = "^([0-9]?[0-9])(:|\.| )?([0-9][0-9])?$";if ( preg_match( $regex, $_POST['user_field_goes_here'], $matches ) ) die( "Ok...it works." );else die( "Nope. Still no good result. =(" );[/code]But when I try to get the groups into $matches array the function returns false?!?!?! Heck it does so even without the $matches array as an argument.The problem is I always get the sad smiley, ok! =S Is there something weird about this function or what?I mean. Try running this:[code]$regex = "^([0-9]?[0-9])(:|\.| )?([0-9][0-9])?$";if ( ereg( $regex, $_POST['user_field_goes_here'] ) ) die( "Jay." );else die( "No." );[/code]Tell me what?! Ahh, you got the "Jay." eh? =) It's weird. Quote Link to comment https://forums.phpfreaks.com/topic/18237-what-the-hll/ Share on other sites More sharing options...
LostOblivion Posted August 21, 2006 Author Share Posted August 21, 2006 Heh. I guess I'm a little tired. Forgot the delimitors. |=[< n00bie[ PROBLEM SOLVED ] Quote Link to comment https://forums.phpfreaks.com/topic/18237-what-the-hll/#findComment-78275 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.