/** * * get regexp token * @param string $char */ public function getRegexpToken($char) { $result = $char; $escape = false; $inCharClass = false; $this->getNextChar(); while (($char = $this->getNextChar()) !== false) { if ($escape) { $result .= "\\" . $char; $escape = false; } else { if ($char === '[') { $inCharClass = true; $result .= $char; } else { if ($char === ']' && $inCharClass) { $inCharClass = false; $result .= $char; } else { if ($char === '/' && !$inCharClass) { break; } else { if ($char === "\\") { $escape = true; } else { $result .= $char; } } } } } } $result .= '/'; $char = $this->text[$this->pos]; if (Fl_Js_Static::isIdentifierStart($char)) { $mods = $this->readWhile('getWordToken'); //check modifier is valid if ($this->validate && !Fl_Js_Static::checkRegexpModifiers($mods)) { $this->throwException('Invalid flags supplied to RegExp constructor "' . $mods . '"'); } } return array($result, $mods); }