ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
class.ilDclTokenizer.php
Go to the documentation of this file.
1 <?php
2 
10 
18  public static function getTokens($expression) {
19  $expression = ltrim($expression, '=');
20  $expression = trim($expression);
21  preg_match_all("/([^\\\\&]|\\\\&)*/ui", $expression, $matches);
22 
23  $results = $matches[0];
24 
25  $return = array();
26  foreach ($results as $r) {
27  if (!$r) {
28  continue;
29  }
30  $return[] = str_ireplace('\&', '&', $r);
31  }
32 
33  return array_map('trim', $return);
34  }
35 
36 
44  public static function getMathTokens($math_expression) {
45  $operators = array_keys(ilDclExpressionParser::getOperators());
46  $pattern = '#((^\[\[)[\d\.]+)|(\(|\)|\\' . implode("|\\", $operators) . ')#';
47  $tokens = preg_split($pattern, $math_expression, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
48 
49  return array_map('trim', $tokens);
50  }
51 }
52 
53 ?>
$r
Definition: example_031.php:79
static getTokens($expression)
Split expression by & (ignore escaped &-symbols with backslash)
$results
static getMathTokens($math_expression)
Generate tokens for a math expression.
Class ilDclTokenizer.