Skip to content

Instantly share code, notes, and snippets.

@graste
Forked from shrink0r/regex_test.php
Created June 25, 2013 12:21
Show Gist options
  • Save graste/5858022 to your computer and use it in GitHub Desktop.
Save graste/5858022 to your computer and use it in GitHub Desktop.
<?php
$pattern = <<<EOT
/
(?(DEFINE)
(?<T_NUM> [0-9] )
)
^(?&T_NUM)$
/x
EOT;
$text = '1';
if (preg_match($pattern, $text))
{
echo "matched!\n";
}
else
{
echo "no match!\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment