mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-09-03 19:30:09 +00:00
24 lines
828 B
PHP
24 lines
828 B
PHP
|
<?php
|
||
|
|
||
|
/*
|
||
|
* This file is part of the Symfony package.
|
||
|
*
|
||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||
|
*
|
||
|
* For the full copyright and license information, please view the LICENSE
|
||
|
* file that was distributed with this source code.
|
||
|
*/
|
||
|
|
||
|
$operators = array('not', '!', 'or', '||', '&&', 'and', '|', '^', '&', '==', '===', '!=', '!==', '<', '>', '>=', '<=', 'not in', 'in', '..', '+', '-', '~', '*', '/', '%', 'matches', '**');
|
||
|
$operators = array_combine($operators, array_map('strlen', $operators));
|
||
|
arsort($operators);
|
||
|
|
||
|
$regex = array();
|
||
|
foreach ($operators as $operator => $length) {
|
||
|
// an operator that ends with a character must be followed by
|
||
|
// a whitespace or a parenthesis
|
||
|
$regex[] = preg_quote($operator, '/').(ctype_alpha($operator[$length - 1]) ? '(?=[\s(])' : '');
|
||
|
}
|
||
|
|
||
|
echo '/'.implode('|', $regex).'/A';
|