Created
February 10, 2015 19:26
-
-
Save allenfernzz/a28cc9d14770980f0747 to your computer and use it in GitHub Desktop.
Time Parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //An Regular Expression Parser for Time followed by a text | |
| function check_for_time() | |
| { | |
| //we are following 24 hour clock pattern | |
| $string = "02:00 am I am still working"; | |
| $pattern = "/([01]?[0-9]|2[0-3]):[0-5][0-9]/"; | |
| if (preg_match($pattern, $string, $matches)) { | |
| echo "<br/>Match was found <br />"; | |
| echo $matches[0]; | |
| } | |
| } | |
| check_for_time(); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment