• Модуль: imconnector
  • Путь к файлу: ~/bitrix/modules/imconnector/lib/connectors/whatsappbyedna.php
  • Класс: BitrixImConnectorConnectorsWhatsappByEdna
  • Вызов: WhatsappByEdna::cleanTextOut
static function cleanTextOut(string $text = ''): string
{
	$text = str_replace(["n", "[br]", "#br#", "[BR]", "#BR#"], "n", $text);
	$text = preg_replace("/[[buis]](.*?)[/[buis]]/i", "$1", $text);
	$text = preg_replace("/\[url\](.*?)\[\/url\]/i" . BX_UTF_PCRE_MODIFIER, "$1", $text);
	$text = preg_replace_callback("/\[url\s*=\s*((?:[^\[\]]++|\[ (?: (?>[^\[\]]+) | (?:\1) )* \])+)\s*\](.*?)\[\/url\]/ixs" . BX_UTF_PCRE_MODIFIER,
		function (&$matches) {
			if ($matches[2] != $matches[1])
				return $matches[2] . ': ' . $matches[1];
			else
				return $matches[1];
		},
		$text);
	$text = preg_replace("/[USER=([0-9]{1,})](.*?)[/USER]/i", "$2", $text);
	$text = preg_replace("/[CHAT=([0-9]{1,})](.*?)[/CHAT]/i", "$2", $text);
	$text = preg_replace("/[SEND(?:=(.+?))?](.+?)?[/SEND]/i", "$2", $text);
	$text = preg_replace("/[PUT(?:=(.+?))?](.+?)?[/PUT]/i", "$2", $text);
	$text = preg_replace("/[CALL(?:=(.+?))?](.+?)?[/CALL]/i", "$2", $text);
	$text = preg_replace("/[PCH=([0-9]{1,})](.*?)[/PCH]/i", "$2", $text);
	$text = preg_replace("/[ATTACH=([0-9]{1,})]/i", "", $text);
	$text = preg_replace("/[ICON=(.+?)]/i", "", $text);

	return $text;
}