You are here

public function RegexTest::provideHtmlPatterns in Plug 7

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Constraints/RegexTest.php, line 28

Class

RegexTest
@author Bernhard Schussek <bschussek@gmail.com>

Namespace

Constraints

Code

public function provideHtmlPatterns() {
  return array(
    // HTML5 wraps the pattern in ^(?:pattern)$
    array(
      '/^[0-9]+$/',
      '[0-9]+',
    ),
    array(
      '/[0-9]+$/',
      '.*[0-9]+',
    ),
    array(
      '/^[0-9]+/',
      '[0-9]+.*',
    ),
    array(
      '/[0-9]+/',
      '.*[0-9]+.*',
    ),
    // We need a smart way to allow matching of patterns that contain
    // ^ and $ at various sub-clauses of an or-clause
    // .*(pattern).* seems to work correctly
    array(
      '/[0-9]$|[a-z]+/',
      '.*([0-9]$|[a-z]+).*',
    ),
    array(
      '/[0-9]$|^[a-z]+/',
      '.*([0-9]$|^[a-z]+).*',
    ),
    array(
      '/^[0-9]|[a-z]+$/',
      '.*(^[0-9]|[a-z]+$).*',
    ),
    // Unescape escaped delimiters
    array(
      '/^[0-9]+\\/$/',
      '[0-9]+/',
    ),
    array(
      '#^[0-9]+\\#$#',
      '[0-9]+#',
    ),
    // Cannot be converted
    array(
      '/^[0-9]+$/i',
      null,
    ),
    // Inverse matches are simple, just wrap in
    // ((?!pattern).)*
    array(
      '/^[0-9]+$/',
      '((?!^[0-9]+$).)*',
      false,
    ),
    array(
      '/[0-9]+$/',
      '((?![0-9]+$).)*',
      false,
    ),
    array(
      '/^[0-9]+/',
      '((?!^[0-9]+).)*',
      false,
    ),
    array(
      '/[0-9]+/',
      '((?![0-9]+).)*',
      false,
    ),
    array(
      '/[0-9]$|[a-z]+/',
      '((?![0-9]$|[a-z]+).)*',
      false,
    ),
    array(
      '/[0-9]$|^[a-z]+/',
      '((?![0-9]$|^[a-z]+).)*',
      false,
    ),
    array(
      '/^[0-9]|[a-z]+$/',
      '((?!^[0-9]|[a-z]+$).)*',
      false,
    ),
    array(
      '/^[0-9]+\\/$/',
      '((?!^[0-9]+/$).)*',
      false,
    ),
    array(
      '#^[0-9]+\\#$#',
      '((?!^[0-9]+#$).)*',
      false,
    ),
    array(
      '/^[0-9]+$/i',
      null,
      false,
    ),
  );
}