Нашел и другое решение - PHP.
функция ween_replace получил: http://dk2.php.net/manual/en/function.str-replace.php#104072
Код:
<?
$sample=$_POST['sample'];
$sample = ereg_replace("[\]", "", $sample);
between_replace ('<u><a target="_blank" href="','">', $sample, "");
$sample = str_replace('<u><a target="_blank" href="', "", $sample);
$sample = str_replace('"><font color="#666666">http://', "", $sample);
$sample = str_replace("</font></a></u>", "", $sample);
$sample = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i", "$1http://$2", $sample);
$sample = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i", "<u><a target=\"_blank\" href=\"$1\"><font color=\"#666666\">$1</font></a></u>", $sample);
$sample = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<u><a href=\"mailto:$1\"><font color=\"#666666\">$1</font></a></u>",$sample);
$sample = ereg_replace("[\n]", "\n", $sample);
$sample = ereg_replace("[']", "''", $sample);
echo "&sampletext=" . $sample."&";
function between_replace ($open, $close, &$in, $with, $limit=false, $from=0)
{
if ($limit!==false && $limit==0)
{
return $in;
}
$open_position = strpos ($in, $open, $from);
if ($open_position===false)
{
return false;
};
$close_position = strpos ($in, $close, $open_position+strlen($open));
if ($close_position===false)
{
return false;
};
$current = false;
if (strpos($with,'{*}')!==false)
{
$current = substr ($in, $open_position+strlen($open), $close_position-$open_position-strlen($open));
$current = str_replace ('{*}',$current,$with);
//debug_echo ($current);
}
else
{
$current = $with;
}
$in = substr_replace ($in, $current, $open_position+strlen($open), $close_position-$open_position-strlen($open));
$next_position = $open_position + strlen($current) + 1;
if ($next_position>=strlen($in))
{
return false;
}
if ($limit!==false)
{
$limit--;
}
between_replace ($open, $close, $in, $with, $limit, $next_position);
return $in;
}
?>