Exemple #1
0
 /**
  * @return mixed|string
  * @throws BuildException
  */
 protected function doReplace()
 {
     if ($this->replace === null) {
         throw new BuildException('No replace expression specified.');
     }
     $this->reg->setPattern($this->pattern);
     $this->reg->setReplace($this->replace);
     $this->reg->setModifiers($this->modifiers);
     $this->reg->setIgnoreCase(!$this->caseSensitive);
     $this->reg->setLimit($this->limit);
     try {
         $output = $this->reg->replace($this->subject);
     } catch (Exception $e) {
         $output = $this->defaultValue;
     }
     return $output;
 }
Exemple #2
0
 /**
  * Converts internal string representation to final HTML code in UTF-8.
  * @return string
  */
 public final function stringToText($s)
 {
     $save = $this->htmlOutputModule->lineWrap;
     $this->htmlOutputModule->lineWrap = FALSE;
     $s = $this->stringToHtml($s);
     $this->htmlOutputModule->lineWrap = $save;
     // remove tags
     $s = Regexp::replace($s, '#<(script|style)(.*)</\\1>#Uis', '');
     $s = strip_tags($s);
     $s = Regexp::replace($s, '#\\n\\s*\\n\\s*\\n[\\n\\s]*\\n#', "\n\n");
     // entities -> chars
     $s = html_entity_decode($s, ENT_QUOTES, 'UTF-8');
     // convert nbsp to normal space and remove shy
     $s = strtr($s, ["­" => '', " " => ' ']);
     return $s;
 }