Adds a pattern for a type.

@param string $type
@param string $pattern
960643
public function addPattern($type, $pattern)
    {
        $this->map[$type] = $pattern;
        unset($this->compileCache[$type]);
    }
952508
protected function addPatternAndReplacement($pattern, $replacement)
    {
        $instance = new \stdClass();
        $instance->pattern = $pattern;
        $instance->replacement = $replacement;
        $this->patternsAndReplacements[] = $instance;
    }
468512
protected function write($pattern = null, ...$args)
    {
        if (!$this->hasOutput()) {
            return $this;
        }

        $this->getOutput()->write(vsprintf($pattern, $args));

        return $this;
    }
526549
protected function regexifyPattern($pattern)
    {
        preg_match_all('/(\/?)\(:([^)]*)\)(\??)/', $pattern, $regExPatterns, PREG_SET_ORDER, 0);

        $pattern = preg_quote($pattern, '/');

        foreach ($regExPatterns as $regExPattern) {
            if (!empty($regExPattern[2]) && key_exists($regExPattern[2], $this->patterns)) {
                $replacement = sprintf(
                    '(%s%s)%s',
                    empty($regExPattern[1]) ? '' : '\/',
                    $this->patterns[$regExPattern[2]],
                    $regExPattern[3]
                );

                $pattern     = str_replace(preg_quote($regExPattern[0], '/'), $replacement, $pattern);
            }
        }

        return "/^$pattern$/";
    }
300532
public function addType(Type $type, $name = '')
    {
        if (!$name) {
            $name = (string)$type;
        }

        $this->types[$name] = $type;
    }
1262496
def addPattern(self, word, vector):
        
        if word in self.patterns:
            raise NetworkError('Pattern key already in use. Call delPattern to free key.', word)
        else:
            self.patterns[word] = vector
66811
public void setPattern(String pattern) {
        if (pattern == null || pattern.length() <= 0) {
            throw new IllegalArgumentException(
                    "Pattern to search for can not be null or of length 0");
        }
        pattern_.text_ = pattern;
        initialize();
    }
465402
public function addPattern($pattern, $childRuleName = null) {
        preg_match_all(
            '/\\\\.|' . // match \.
            '\(\?|[()]|' . // match "(" or ")"
            '\[\^?\]?(?:\\\\.|\[:[^]]*:\]|[^]\\\\])*\]|' . // match combination of "[]"
            '[^[()\\\\]+/', // match not in list "()\"
            $pattern, $matches);

        $groupDeep = 0;
        $pattern = '(';

        foreach ($matches[0] as $match) {
            switch ($match) {
                case '(':
                    $pattern .= '\\(';
                    break;

                case ')':
                    if ($groupDeep > 0) {
                        $groupDeep--;
                    } else {
                        $pattern .= '\\';
                    }
                    $pattern .= ')';
                    break;

                case '(?':
                    $groupDeep++;
                    $pattern .= '(?';
                    break;

                default:
                    $pattern .= substr($match, 0, 1) == '\\'
                        ? $match
                        : str_replace('/', '\\/', $match);
                    break;
            }
        }

        $pattern .= ')';

        $this->patterns[] = [
            'pattern'       => $pattern,
            'childRuleName' => $childRuleName,
        ];
    }
150665
private void addPattern(MethodSpec.Builder method, String pattern) {
    // Parse the pattern and populate the method body with instructions to format the date.
    for (Node node : DATETIME_PARSER.parse(pattern)) {
      if (node instanceof Text) {
        method.addStatement("b.append($S)", ((Text)node).text());
      } else if (node instanceof Field) {
        Field field = (Field)node;
        method.addStatement("formatField(d, '$L', $L, b)", field.ch(), field.width());
      }
    }
  }
903581
public function put(string $pattern, callable $callback)
    {
        if ($this->requestMethod === "PUT") {
            $this->mapRoute($pattern, $callback);
        }
    }
343668
protected function writeln($pattern = null, ...$args)
    {
        if (!$this->hasOutput()) {
            return $this;
        }

        $this->getOutput()->writeln(vsprintf($pattern, $args));

        return $this;
    }
141368
public function like($column, $pattern)
    {
        $this->conditions = [$this->grammar->buildId($column) . ' LIKE ' . $pattern];

        return $this;
    }
907114
def add_pattern(self, pattern, category=SourceRootCategories.UNKNOWN):
    """"""
    self._do_add_pattern(pattern, tuple(), category)
1038975
public function setPattern($pattern)
    {
        if (!is_array($pattern) && !is_string($pattern)) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s expects pattern to be array or string; received "%s"',
                __METHOD__,
                (is_object($pattern) ? get_class($pattern) : gettype($pattern))
            ));
        }

        if (is_array($pattern)) {
            foreach ($pattern as $p) {
                $this->validatePattern($p);
            }
        }

        if (is_string($pattern)) {
            $this->validatePattern($pattern);
        }

        $this->options['pattern'] = $pattern;
        return $this;
    }
1315721
public function doAddPattern($pattern)
    {
        if (0 === strpos($pattern, '!')) {
            $searchPattern = substr($pattern, 1);
            $this->finder->notPath(Glob::toRegex($searchPattern, true, true));

            $pathComponents = explode('/', $searchPattern);

            if (1 < \count($pathComponents)) {
                $parentDirectories = \array_slice($pathComponents, 0, -1);
                $basePath = '';

                foreach ($parentDirectories as $dir) {
                    $this->finder->notPath('/\b('.preg_quote($basePath.$dir, '/').')(?!\/)\b/');
                    $basePath .= $dir.'/';
                }
            }
        } else {
            $this->finder->path(Glob::toRegex($pattern, true, true));
        }
    }
37035
public function addRaw(string $pattern): self
    {
        if (substr($pattern, 0, 2)=='./') {
            $pattern = substr($pattern, 2);
        }
        if (!in_array($pattern, $this->raws)) {
            $this->raws[] = $pattern;
        }

        return $this;
    }
252765
public void addModeForPattern(String pattern, Integer mode) {
        System.out.println(String.format("*** Recording pattern \"%s\" with mode %o", pattern, mode));
        patternToModeMap.put(pattern, mode);
    }