Skip to content

Instantly share code, notes, and snippets.

@allenfernzz
Created February 10, 2015 19:26
Show Gist options
  • Select an option

  • Save allenfernzz/a28cc9d14770980f0747 to your computer and use it in GitHub Desktop.

Select an option

Save allenfernzz/a28cc9d14770980f0747 to your computer and use it in GitHub Desktop.

Revisions

  1. Allen Fernandes created this gist Feb 10, 2015.
    16 changes: 16 additions & 0 deletions index.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <?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();
    ?>