Inspekt\Inspekt::isRegex PHP Method

isRegex() public static method

Returns true if value matches $pattern, false otherwise. Uses preg_match() for the matching.
public static isRegex ( mixed $value, mixed $pattern ) : mixed
$value mixed
$pattern mixed
return mixed
    public static function isRegex($value, $pattern)
    {
        return (bool) preg_match($pattern, $value);
    }

Usage Example

コード例 #1
0
ファイル: InspektTest.php プロジェクト: funkatron/inspekt
 /**
  * @todo Implement testIsRegex().
  */
 public function testIsRegex()
 {
     $input = 'username_786';
     $regex = '/[a-zA-Z0-9_]/';
     $this->assertTrue(Inspekt::isRegex($input, $regex));
 }