<?php
function is_valid_regex($pattern)
{
}
$patterns = array('/[[0-9]/i', '//(.*)/', '/(.*)-(.*)-(.*)/ ', '/([a-z]+)-([0-9_]+)/i');
foreach ($patterns as $pattern)
{
echo sprintf('%s is %b' . "\n", $pattern, is_valid_regex
($pattern)); }
PD9waHAKCmZ1bmN0aW9uIGlzX3ZhbGlkX3JlZ2V4KCRwYXR0ZXJuKQp7CiAgICByZXR1cm4gaXNfaW50KEBwcmVnX21hdGNoKCRwYXR0ZXJuLCAnJykpOwp9CgokcGF0dGVybnMgPSBhcnJheSgnL1tbMC05XS9pJywgJy8vKC4qKS8nLCAnLyguKiktKC4qKS0oLiopLyAnLCAnLyhbYS16XSspLShbMC05X10rKS9pJyk7Cgpmb3JlYWNoICgkcGF0dGVybnMgYXMgJHBhdHRlcm4pCnsKICAgIGVjaG8gc3ByaW50ZignJXMgaXMgJWInIC4gIlxuIiwgJHBhdHRlcm4sIGlzX3ZhbGlkX3JlZ2V4KCRwYXR0ZXJuKSk7Cn0=