protected function remove_noise($pattern, $remove_tag = false)
{
global $debugObject;
if (is_object($debugObject)) {
$debugObject->debugLogEntry(1);
}
$count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
for ($i = $count - 1; $i > -1; --$i) {
$key = '___noise___' . sprintf('% 5d', count($this->noise) + 1000);
if (is_object($debugObject)) {
$debugObject->debugLog(2, 'key is: ' . $key);
}
$idx = $remove_tag ? 0 : 1;
$this->noise[$key] = $matches[$i][$idx][0];
$this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
}
// reset the length of content
$this->size = strlen($this->doc);
if ($this->size > 0) {
$this->char = $this->doc[0];
}
}