Sort regexps by length

@return void
340107
protected function sortRegexps()
	{
		uasort(
			$this->regexps,
			function ($a, $b)
			{
				return strlen($b) - strlen($a);
			}
		);
	}
835099
private function parseShortString()
    {
        $length = \ord($this->buffer);

        try {
            return mb_orig_substr($this->buffer, 1, $length);
        } finally {
            $this->buffer = mb_orig_substr($this->buffer, $length + 1);
        }
    }
150059
def sort_matches(matches):
    ''''''
    multipliers = {'exact':10**5,'fname':10**4,'fuzzy':10**2,'fuzzy_fragment':1}
    matches = [(multipliers[x.type]*(x.amount if x.amount else 1),x) for x in matches]
    return [x[1] for x in sorted(matches,reverse=True)]
1039683
private function skipToNextStringOrNamespaceSeparator(\ArrayIterator $tokens)
    {
        while ($tokens->valid() && (T_STRING !== $tokens->current()[0]) && (T_NS_SEPARATOR !== $tokens->current()[0])) {
            $tokens->next();
        }
    }
792135
protected function saveRegex()
	{
		echo $this->a . $this->b;

		while (($this->a = $this->getChar()) !== false)
		{
			if ($this->a === '/')
			{
				break;
			}

			if ($this->a === '\\')
			{
				echo $this->a;
				$this->a = $this->getChar();
			}

			if ($this->a === "\n")
			{
				throw new \RuntimeException('Unclosed regex pattern at position: ' . $this->index);
			}

			echo $this->a;
		}

		$this->b = $this->getReal();
	}
852139
protected function sortOrderString()
    {
        $sortOrderComponents = [];
        foreach ($this->getSortOrder() as $sortCriterion) {
            $sortOrderComponents[] = $sortCriterion['fieldName'] . ':'
                    . (($sortCriterion['direction'] === 'descending') ? '0' : '1');
        }
        $sortOrderString = implode(',', $sortOrderComponents);

        return $sortOrderString;
    }
204794
protected static function evaluateConcat($expr)
	{
		preg_match_all('(\'[^\']*\'|"[^"]*")', $expr, $strings);

		$value = '';
		foreach ($strings[0] as $string)
		{
			$value .= substr($string, 1, -1);
		}

		return $value;
	}
933381
public function sort ()
    {
        usort($this->_fields,
              function (Field $fieldA, Field $fieldB) {
              return strcmp($fieldA->getShorthand(), $fieldB->getShorthand());
          });
    }
1174255
private function compile()
    {
        // replace pseudo {param}:type syntax to valid regex
        if (strpos($this->regex, '}:') !== false) {
            $this->regex = preg_replace('#\{([a-zA-Z0-9_-]+)\}:([a-z]+)#', '(?P<$1>:$2)', $this->expression);
            $this->regex = str_replace(
                array_keys($this->regexExpression),
                array_values($this->regexExpression),
                $this->regex
            );
        }

        // replace pseudo {param} syntax without type to valid regex
        if (strpos($this->regex, '}') !== false) {
            $this->regex = preg_replace('#\{([a-zA-Z_]+)\}#', '(?P<$1>[^\/]+)', $this->regex);
        }

        // allow optional trailing slash at the end
        if (substr($this->regex, -1) !== '/') {
            $this->regex .= '[\/]?';
        }
    }
539748
public function sortAsc()
    {
        $cmp = function (TagInterface $a, TagInterface $b) {
            if ($a->getName() == $b->getName()) {
                return 0;
            }

            return ($a->getName() < $b->getName()) ? -1 : 1;
        };
        usort($this->elements, $cmp);
    }
992119
public function order($expr)
    {
        $matches = array();

        $expr = (array)$expr;

        $result = array();

        foreach($expr as $e) {
            // basic syntax, with asc/desc suffix
            if (preg_match('/([a-z_0-9.]+) (asc|desc)$/i', $e)) {
                $result[] = $e;
            } else if (preg_match('/([\+\-]?)([a-z_0-9.]+)/i', $e, $matches)) {

                // alternative syntax - with +/- prefix
                $subResult = $matches[2];
                if ($matches[1] == '' || $matches[1] == '+') {
                    $subResult .= ' asc';
                } else {
                    $subResult .= ' desc';
                }
                $result[] = $subResult;
            } else {
                // something which should never happen but take care [;
                throw new \RuntimeException('Cannot understand ordering expression', ResourceException::ORDER_NOT_SUPPORTED);
            }
        }

        $this->order = $result;

    }
97862
protected function getAttributeNamesFromRegexps(array $regexps)
	{
		$attrNames = [];
		foreach ($regexps as list($regexp, $map))
		{
			$attrNames += array_flip(array_filter($map));
		}

		return $attrNames;
	}
426415
protected function get_calculated_regexp() {
        $regexp = '/\$@' . $this->linkname;
        foreach ($this->mappings as $key => $value) {
            $regexp .= '\*(\d+)';
        }
        $regexp .= '@\$/';
        return $regexp;
    }
216382
function concatRegexes (regexes) {
  var rconcat = ''

  if (Array.isArray(regexes)) {
    for (var i = 0, l = regexes.length; i < l; i++) {
      rconcat += regexes[i].source + '|'
    }

    rconcat = rconcat.substr(0, rconcat.length - 1)

    return new RegExp(rconcat)
  }
}
637896
def re_filter(text, regexps):
    """"""
    if not regexps:
        return text

    matched_text = []
    compiled_regexps = [re.compile(x) for x in regexps]
    for line in text:
        if line in matched_text:
            continue

        for regexp in compiled_regexps:
            found = regexp.search(line)
            if found and found.group():
                matched_text.append(line)

    return matched_text or text
400298
public function fragmentize() {
        $re = implode('|', array(
            self::RE_SHORT_TOKEN_START, self::RE_SHORT_TOKEN_END,
            self::RE_LONG_TOKEN_START, self::RE_LONG_TOKEN_END,
            self::RE_TEXT
        ));

        preg_match_all('/'.$re.'/', $this->text, $matches);
        $this->fragments = $matches[0];
        $this->tokens = array();
    }
654787
protected function parseFractions()
	{
		if (strpos($this->text, '/') === false)
		{
			return;
		}

		$map = [
			'1/4'  => "\xC2\xBC",
			'1/2'  => "\xC2\xBD",
			'3/4'  => "\xC2\xBE",
			'1/7'  => "\xE2\x85\x90",
			'1/9'  => "\xE2\x85\x91",
			'1/10' => "\xE2\x85\x92",
			'1/3'  => "\xE2\x85\x93",
			'2/3'  => "\xE2\x85\x94",
			'1/5'  => "\xE2\x85\x95",
			'2/5'  => "\xE2\x85\x96",
			'3/5'  => "\xE2\x85\x97",
			'4/5'  => "\xE2\x85\x98",
			'1/6'  => "\xE2\x85\x99",
			'5/6'  => "\xE2\x85\x9A",
			'1/8'  => "\xE2\x85\x9B",
			'3/8'  => "\xE2\x85\x9C",
			'5/8'  => "\xE2\x85\x9D",
			'7/8'  => "\xE2\x85\x9E",
			'0/3'  => "\xE2\x86\x89"
		];

		$regexp = '/\\b(?:0\\/3|1\\/(?:[2-9]|10)|2\\/[35]|3\\/[458]|4\\/5|5\\/[68]|7\\/8)\\b/S';
		preg_match_all($regexp, $this->text, $matches, PREG_OFFSET_CAPTURE);
		foreach ($matches[0] as $m)
		{
			$this->addTag($m[1], strlen($m[0]), $map[$m[0]]);
		}
	}