/** * @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; }