ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 ?>