@ld6666666666666

Как заменить eregi на preg?

Как заменить eregi на preg?

static function makeClickableLinks($text)
	{ 

		 $text = @eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', 
		   '<a rel="nofollow" target="_blank" href="/go/?url=\\1">\\1</a>', $text);
		 $text = @eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', 
		   '\\1<a rel="nofollow" target="_blank" href="/go?url=http://\\2">\\2</a>', $text);
		  
		return $text;
	}
}
  • Вопрос задан
  • 2382 просмотра
Решения вопроса 1
static function makeClickableLinks($text)
{

	$text = preg_replace('/(((f|ht){1}tp:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i',
		'<a rel="nofollow" target="_blank" href="/go/?url=\\1">\\1</a>', $text);
	$text = preg_replace('/([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i',
		'\\1<a rel="nofollow" target="_blank" href="/go?url=http://\\2">\\2</a>', $text);

	return $text;
}
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы