PHP code example of hylianshield / validator-pcre

1. Go to this page and download the library: Download hylianshield/validator-pcre library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hylianshield / validator-pcre example snippets


$expression = new \HylianShield\Validator\Pcre\Expression('/foo/');

echo $expression->getPattern(); // "/foo/"

$validator = new \HylianShield\Validator\Pcre\ExpressionValidator('/foo/');

echo $validator->getPattern(); // "/foo/"
echo $validator->getIdentifier(); // "pcre(/foo/)"

$validator->validate('foo'); // true
$validator->validate('bar'); // false