Add a meta-character to the list

@param  string $char Meta-character
@param  string $expr Regular expression
@return void
177725
public function add($char, $expr)
	{
		$split = $this->input->split($char);
		if (count($split) !== 1)
		{
			throw new InvalidArgumentException('Meta-characters must be represented by exactly one character');
		}
		if (@preg_match('(' . $expr . ')u', '') === false)
		{
			throw new InvalidArgumentException("Invalid expression '" . $expr . "'");
		}

		$inputValue = $split[0];
		$metaValue  = $this->computeValue($expr);

		$this->exprs[$metaValue] = $expr;
		$this->meta[$inputValue] = $metaValue;
	}
1299442
protected function getTextContent($expr)
	{
		$expr = trim($expr);

		if (preg_match('(^(?:\'[^\']*\'|"[^"]*")$)', $expr))
		{
			return substr($expr, 1, -1);
		}

		if (preg_match('(^0*([0-9]+(?:\\.[0-9]+)?)$)', $expr, $m))
		{
			// NOTE: we specifically ignore leading zeros
			return $m[1];
		}

		return false;
	}
914314
public function setExpression(string $expr) {
		$this->expression = $expr;
		$this->hasExpression = true;

		return $this;
	}
860113
protected function _compileCondExpression($expr)
    {
        if (strpos($expr, ',') !== false) {
            $parts = explode(',', $expr);
            $cond = trim($parts[0]);
            $true = trim($parts[1]);
            $false = isset($parts[2]) ? trim($parts[2]) : 0;

            $true = is_numeric($true) ? (float)$true : '$' . $true;
            $false = is_numeric($false) ? (float)$false : '$' . $false;
        } else {
            $cond = $expr;
            $true = 1;
            $false = 0;
        }

        if (preg_match('#^(.+)\s*([<>=]+)\s*(.+)$#', $cond, $match)) {
            list(, $op1, $op2, $op3) = $match;
            $alg = ['=' => '$eq', '>' => '$gt', '>=' => '$gte', '<' => '$lt', '<=' => '$lte', '!=' => '$neq', '<>' => '$neq'];
            return ['$cond' => [[$alg[$op2] => [is_numeric($op1) ? (float)$op1 : '$' . $op1, is_numeric($op3) ? (float)$op3 : '$' . $op3]], $true, $false]];
        } else {
            return null;
        }
    }
456489
public function insert(string $string) {
        $node = $this->root;
        for ($i = 0; $i < \strlen($string); $i++) {
            $charIndex = $this->getCharIndex($string[$i]);
            if (!$node->hasChild($charIndex)) {
                $node->createChildNode($charIndex);
            }
            $node = $node->getChildNode($charIndex);
        }
        $node->createEndOfWordNode();
    }
1019659
public static function valueOf($char): self
    {
        if (\is_string($char) || $char instanceof self) {
            return new static((string) $char);
        }

        throw new InvalidArgumentException('Unsupported character type!');
    }
391816
public function whereStartsWith($expr, $value, $length = null)
    {
        return $value === '' ? $this : $this->whereLike($expr, $length === null ? $value . '%' : str_pad($value, $length, '_'));
    }
473198
public void add(CharRange cond)
    {
        if (set.isEmpty())
        {
            set.add(cond);
        }
        else
        {
            List<CharRange> remlist = new ArrayList<CharRange>();
            List<CharRange> addlist = new ArrayList<CharRange>();
            boolean is = false;
            for (CharRange r : set)
            {
                if (r.intersect(cond))
                {
                    remlist.add(r);
                    addlist.addAll(CharRange.removeOverlap(cond, r));
                    is = true;
                }
            }
            if (!is)
            {
                set.add(cond);
            }
            set.removeAll(remlist);
            set.addAll(addlist);
        }
    }
640334
private function assertCharacterClass(string $chars): void
	{
		SlugGenerator::checkPcreSupport();

		if ($chars !== '' && ($chars[0] === '^' || @preg_match('(^['.$chars.']?$)u', '') !== 1)) {
			throw new \InvalidArgumentException(sprintf('Invalid regular expression character class "%s"', $chars));
		}
	}
1160356
public static function parseEventExpr($expr)
    {
        if (!preg_match('#^([\w*.,]+)(/([\w*.,]+)(/([\w*.,]+))?)?$#i', $expr, $matches)) {
            throw new \InvalidArgumentException('The expression must be in the format "topic/event?/version?"');
        }

        $topic = $matches[1];
        $event = isset($matches[3]) ? $matches[3] : '*';
        $version = isset($matches[5]) ? $matches[5] : '*';

        if ($topic === '*') {
            $event = $version = '*';
        } elseif ($event === '*') {
            $version = '*';
        }

        return [
            'topic' => $topic,
            'event' => $event,
            'version' => $version,
        ];
    }
1372031
private function build( $pString ) {
        for ( $i=0; $i < strlen( $pString ); $i++ ) { 
            $this->addChar( $pString[$i] );
        }
    }
683100
public function addToQueryCondition(Expr $expr)
    {
        $expr->attr($this->getHashKey()->getPropertyMetadata()->name)->equals($this->getHashValue());
    }
1286473
public static function isExpressionNumeric($expr)
	{
		// Trim the expression and remove parentheses that are not part of a function call. PCRE
		// does not support lookbehind assertions of variable length so we have to flip the string.
		// We exclude the XPath operator "div" (flipped into "vid") to avoid false positives
		$expr = strrev(preg_replace('(\\((?!\\s*(?!vid(?!\\w))\\w))', ' ', strrev($expr)));
		$expr = str_replace(')', ' ', $expr);
		if (preg_match('(^\\s*([$@][-\\w]++|-?\\.\\d++|-?\\d++(?:\\.\\d++)?)(?>\\s*(?>[-+*]|div)\\s*(?1))++\\s*$)', $expr))
		{
			return true;
		}

		return false;
	}
281816
public void add(char ch) {
		if (b.length <= i) {
			b = ArrayUtil.grow(b, i + 1);
		}
		b[i++] = ch;
	}
339803
public function setValidChars(string $chars): self
	{
		$this->assertCharacterClass($chars);

		$this->validChars = $chars;
		$this->setOptions['validChars'] = null;

		return $this;
	}
150014
public static function mustBeginWith($character = '/', $string = ''){
        if (strlen($string) > 0) {
            if (substr($string, 0, 1) != $character) {
                return $character.$string;
            } else {
                return $string;
            }
        } else {
            return $character;
        }
    }
975703
def add_chars(self, chars):
        ''
        for c in chars:
            if self._ignorecase:
                self._whitelist_chars.add(c.lower())
                self._whitelist_chars.add(c.upper())
            else:
                self._whitelist_chars.add(c)