preg_quote example


  public static function sqlFunctionLikeBinary($pattern$subject) {
    // Replace the SQL LIKE wildcard meta-characters with the equivalent regular     // expression meta-characters and escape the delimiter that will be used for     // matching.     $pattern = str_replace(['%', '_']['.*?', '.']preg_quote($pattern, '/'));
    return preg_match('/^' . $pattern . '$/', $subject);
  }

  public function queryRange($query$from$count, array $args = [], array $options = []) {
    return $this->query($query . ' LIMIT ' . (int) $from . ', ' . (int) $count$args$options);
  }

  /** * {@inheritdoc} */
  public function queryTemporary($query, array $args = [], array $options = []) {
    

        }
    }

    /** * Set the Platform */
    protected function setPlatform(): bool
    {
        if (is_array($this->config->platforms) && $this->config->platforms) {
            foreach ($this->config->platforms as $key => $val) {
                if (preg_match('|' . preg_quote($key, '|') . '|i', $this->agent)) {
                    $this->platform = $val;

                    return true;
                }
            }
        }

        $this->platform = 'Unknown Platform';

        return false;
    }

    
self::OPERATOR_EMPTY => empty($zipCode),
            default => throw new UnsupportedOperatorException($this->operator, self::class),
        };
    }

    /** * @return array<string> */
    private function getMatches(string $zipCode): array
    {
        return array_filter((array) $this->zipCodes, function Dstring $zipCodeMatch) use ($zipCode) {
            $zipCodeMatch = str_replace('\*', '(.*?)', preg_quote($zipCodeMatch, '/'));
            $regex = sprintf('/^%s$/i', $zipCodeMatch);

            return preg_match($regex$zipCode) === 1;
        });
    }

    private function sanitizeZipCode(CustomerAddressEntity $address): string
    {
        $zipCode = trim($address->getZipcode() ?? '');

        if (\in_array($this->operator, [self::OPERATOR_EQ, self::OPERATOR_NEQ], true)) {
            
return true;
        }

        static $bypass_hosts   = null;
        static $wildcard_regex = array();
        if ( null === $bypass_hosts ) {
            $bypass_hosts = preg_split( '|,\s*|', WP_PROXY_BYPASS_HOSTS );

            if ( str_contains( WP_PROXY_BYPASS_HOSTS, '*' ) ) {
                $wildcard_regex = array();
                foreach ( $bypass_hosts as $host ) {
                    $wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
                }
                $wildcard_regex = '/^(' . implode( '|', $wildcard_regex ) . ')$/i';
            }
        }

        if ( ! empty( $wildcard_regex ) ) {
            return ! preg_match( $wildcard_regex$check['host'] );
        } else {
            return ! in_array( $check['host']$bypass_hosts, true );
        }
    }
}
$definition = $container->getDefinition(FooClassWithEnumAttribute::class);
        $this->assertSame([FooUnitEnum::BAR]$definition->getArguments());
    }

    public function testNestedBundleConfigNotAllowed()
    {
        $fixtures = realpath(__DIR__.'/../Fixtures');
        $container = new ContainerBuilder();
        $loader = new PhpFileLoader($containernew FileLocator(), 'prod', new ConfigBuilderGenerator(sys_get_temp_dir()));

        $this->expectException(\InvalidArgumentException::class);
        $this->expectExceptionMessageMatches('/^'.preg_quote('Could not resolve argument "Symfony\\Config\\AcmeConfig\\NestedConfig $config"', '/').'/');

        $loader->load($fixtures.'/config/nested_bundle_config.php');
    }

    public function testWhenEnv()
    {
        $this->expectNotToPerformAssertions();

        $fixtures = realpath(__DIR__.'/../Fixtures');
        $container = new ContainerBuilder();
        $loader = new PhpFileLoader($containernew FileLocator(), 'dev', new ConfigBuilderGenerator(sys_get_temp_dir()));

        
$word = trim( $word );

            // Skip empty lines.             if ( empty( $word ) ) {
                continue;
            }

            /* * Do some escaping magic so that '#' (number of) characters in the spam * words don't break things: */
            $word = preg_quote( $word, '#' );

            /* * Check the comment fields for moderation keywords. If any are found, * fail the check for the given field by returning false. */
            $pattern = "#$word#iu";
            if ( preg_match( $pattern$author ) ) {
                return false;
            }
            if ( preg_match( $pattern$email ) ) {
                return false;
            }
if ( empty( $title ) ) {
            return $this->pingback_error( 32, __( 'A title on that page cannot be found.' ) );
        }

        // Remove all script and style tags including their content.         $remote_source = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $remote_source );
        // Just keep the tag we need.         $remote_source = strip_tags( $remote_source, '<a>' );

        $p = explode( "\n\n", $remote_source );

        $preg_target = preg_quote( $pagelinkedto, '|' );

        foreach ( $p as $para ) {
            if ( str_contains( $para$pagelinkedto ) ) { // It exists, but is it a link?                 preg_match( '|<a[^>]+?' . $preg_target . '[^>]*>([^>]+?)</a>|', $para$context );

                // If the URL isn't in a link context, keep looking.                 if ( empty( $context ) ) {
                    continue;
                }

                /* * We're going to use this fake tag to mark the context in a bit. * The marker is needed in case the link text appears more than once in the paragraph. */
$provider = false;

        if ( ! isset( $args['discover'] ) ) {
            $args['discover'] = true;
        }

        foreach ( $this->providers as $matchmask => $data ) {
            list( $providerurl$regex ) = $data;

            // Turn the asterisk-type provider URLs into regex.             if ( ! $regex ) {
                $matchmask = '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $matchmask ), '#' ) ) . '#i';
                $matchmask = preg_replace( '|^#http\\\://|', '#https?\://', $matchmask );
            }

            if ( preg_match( $matchmask$url ) ) {
                $provider = str_replace( '{format}', 'json', $providerurl ); // JSON is easier to deal with than XML.                 break;
            }
        }

        if ( ! $provider && $args['discover'] ) {
            $provider = $this->discover( $url );
        }
        } elseif ( 'custom' === $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) {
            $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );

            // If it's the customize page then it will strip the query var off the URL before entering the comparison block.             if ( is_customize_preview() ) {
                $_root_relative_current = strtok( untrailingslashit( $_SERVER['REQUEST_URI'] ), '?' );
            }

            $current_url        = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current );
            $raw_item_url       = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url;
            $item_url           = set_url_scheme( untrailingslashit( $raw_item_url ) );
            $_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) );

            $matches = array(
                $current_url,
                urldecode( $current_url ),
                $_indexless_current,
                urldecode( $_indexless_current ),
                $_root_relative_current,
                urldecode( $_root_relative_current ),
            );

            if ( $raw_item_url && in_array( $item_url$matches, true ) ) {
                
            // Mandate at least 1 root dir and not more than 5 optional dirs.
            $dir = explode(\DIRECTORY_SEPARATOR, realpath($dir));
            $i = \count($dir);

            if (2 + (int) ('\\' === \DIRECTORY_SEPARATOR) <= $i) {
                $regex = '';
                $lastOptionalDir = $i > 8 ? $i - 5 : (2 + (int) ('\\' === \DIRECTORY_SEPARATOR));
                $this->targetDirMaxMatches = $i - $lastOptionalDir;

                while (--$i >= $lastOptionalDir) {
                    $regex = sprintf('(%s%s)?', preg_quote(\DIRECTORY_SEPARATOR.$dir[$i], '#')$regex);
                }

                do {
                    $regex = preg_quote(\DIRECTORY_SEPARATOR.$dir[$i], '#').$regex;
                } while (0 < --$i);

                $this->targetDirRegex = '#(^|file://|[:;, \|\r\n])'.preg_quote($dir[0], '#').$regex.'#';
            }
        }

        $proxyClasses = $this->inlineFactories ? $this->generateProxyClasses() : null;

        


        return array_keys($classes);
    }

    private function patternsToRegexps(array $patterns): array
    {
        $regexps = [];

        foreach ($patterns as $pattern) {
            // Escape user input             $regex = preg_quote(ltrim($pattern, '\\'));

            // Wildcards * and **             $regex = strtr($regex['\\*\\*' => '.*?', '\\*' => '[^\\\\]*?']);

            // If this class does not end by a slash, anchor the end             if (!str_ends_with($regex, '\\')) {
                $regex .= '$';
            }

            $regexps[] = '{^\\\\'.$regex.'}';
        }

        

#[Package('core')] class ConfigJsonFieldAccessorBuilder extends JsonFieldAccessorBuilder
{
    public function buildAccessor(string $root, Field $field, Context $context, string $accessor): ?string
    {
        if (!$field instanceof ConfigJsonField) {
            return null;
        }

        $jsonPath = preg_replace(
            '#^' . preg_quote($field->getPropertyName(), '#') . '#',
            '',
            $accessor
        );

        $accessor = $field->getPropertyName() . '.' . ConfigJsonField::STORAGE_KEY . $jsonPath;

        return parent::buildAccessor($root$field$context$accessor);
    }
}
      $to_replace = [
        // Replace newlines with a logical 'or'.         '/(\r\n?|\n)/',
        // Quote asterisks.         '/\\\\\*/',
        // Quote <front> keyword.         '/(^|\|)\\\\<front\\\\>($|\|)/',
      ];
      $replacements = [
        '|',
        '.*',
        '\1' . preg_quote($this->getFrontPagePath(), '/') . '\2',
      ];
      $patterns_quoted = preg_quote($patterns, '/');
      $this->regexes[$patterns] = '/^(' . preg_replace($to_replace$replacements$patterns_quoted) . ')$/';
    }
    return (bool) preg_match($this->regexes[$patterns]$path);
  }

  /** * {@inheritdoc} */
  public function isFrontPage() {
    
      $this->assertEquals($theme_machine_name$this->config('system.theme')->get('default'));

      // This checks for a regression. See https://www.drupal.org/node/2498691.       $this->assertSession()->pageTextNotContains("The $theme_machine_name theme was not found.");

      $themes = \Drupal::service('theme_handler')->rebuildThemeData();
      $version = $themes[$theme_machine_name]->info['version'];

      // Confirm the theme is indicated as the default theme and administration       // theme because the admin theme is the default theme.       $out = $this->getSession()->getPage()->getContent();
      $this->assertTrue((bool) preg_match("/$theme_name " . preg_quote($version) . '\s{2,}\(default theme, administration theme\)/', $out));
    }
  }

  /** * Tests the theme settings form when logo and favicon features are disabled. */
  public function testThemeSettingsNoLogoNoFavicon() {
    // Install theme with no logo and no favicon feature.     $this->container->get('theme_installer')->install(['test_theme_settings_features']);
    // Visit this theme's settings page.     $this->drupalGet('admin/appearance/settings/test_theme_settings_features');
    


    $custom_font_size = $block['attrs']['style']['typography']['fontSize'];
    $fluid_font_size  = wp_get_typography_font_size_value( array( 'size' => $custom_font_size ) );

    /* * Checks that $fluid_font_size does not match $custom_font_size, * which means it's been mutated by the fluid font size functions. */
    if ( ! empty( $fluid_font_size ) && $fluid_font_size !== $custom_font_size ) {
        // Replaces the first instance of `font-size:$custom_font_size` with `font-size:$fluid_font_size`.         return preg_replace( '/font-size\s*:\s*' . preg_quote( $custom_font_size, '/' ) . '\s*;?/', 'font-size:' . esc_attr( $fluid_font_size ) . ';', $block_content, 1 );
    }

    return $block_content;
}

/** * Checks a string for a unit and value and returns an array * consisting of `'value'` and `'unit'`, e.g. array( '42', 'rem' ). * * @since 6.1.0 * * @param string|int|float $raw_value Raw size value from theme.json. * @param array $options { * Optional. An associative array of options. Default is empty array. * * @type string $coerce_to Coerce the value to rem or px. Default `'rem'`. * @type int $root_size_value Value of root font size for rem|em <-> px conversion. Default `16`. * @type string[] $acceptable_units An array of font size units. Default `array( 'rem', 'px', 'em' )`; * } * @return array|null An array consisting of `'value'` and `'unit'` properties on success. * `null` on failure. */
Home | Imprint | This part of the site doesn't use cookies.