ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclTokenizer.php
Go to the documentation of this file.
1 <?php
2 
10 
21  public static function getTokens($expression) {
22  $expression = ltrim($expression, '=');
23  $expression = trim($expression);
24  preg_match_all("/([^\\\\&]|\\\\&)*/ui", $expression, $matches);
25 
26  $results = $matches[0];
27 
28  $return = array();
29  foreach ($results as $r) {
30  if (!$r) {
31  continue;
32  }
33  $return[] = str_ireplace('\&', '&', $r);
34  }
35 
36  return array_map('trim', $return);
37  }
38 
39 
47  public static function getMathTokens($math_expression) {
48  $operators = array_keys(ilDclExpressionParser::getOperators());
49  $pattern = '#((^\[\[)[\d\.]+)|(\(|\)|\\' . implode("|\\", $operators) . ')#';
50  $tokens = preg_split($pattern, $math_expression, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
51 
52  return array_map('trim', $tokens);
53  }
54 }
55 
56 ?>
$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.
Create styles array
The data for the language used.
Class ilDclTokenizer.