ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDclTokenizer.php
Go to the documentation of this file.
1<?php
2
10{
11
19 public static function getTokens($expression)
20 {
21 $expression = ltrim($expression, '=');
22 $expression = trim($expression);
23 preg_match_all("/([^\\\\&]|\\\\&)*/ui", $expression, $matches);
24
25 $results = $matches[0];
26
27 $return = array();
28 foreach ($results as $r) {
29 if (!$r) {
30 continue;
31 }
32 $return[] = str_ireplace('\&', '&', $r);
33 }
34
35 return array_map('trim', $return);
36 }
37
38
46 public static function getMathTokens($math_expression)
47 {
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}
An exception for terminatinating execution or to throw for unit testing.
Class ilDclTokenizer.
static getMathTokens($math_expression)
Generate tokens for a math expression.
static getTokens($expression)
Split expression by & (ignore escaped &-symbols with backslash)
$results