code: protected function _replaceLoop($pattern, $replace, &$text)
      {
          while (preg_match($pattern, $text)) {
              if (is_string($replace)) {
                  $text = preg_replace($pattern, $replace, $text);
              } else {
                  $text = preg_replace_callback($pattern, $replace, $text);
              }
          }
      }
docs: parse bbcode corespondig to $pattern inside $text and replace with $replace
  
  @param string $pattern
  @param string|callback $replace
  @param string $text
  @uses preg_replace