如何获取链接文字(如降价)。说一些类型
class PricesTable[PriceList <: HList](prices: PriceList)(implicit lubC: LUBConstraint[PriceList, Price[_]]) {
def priceFor[C <: Country](implicit selector: Selector[PriceList, Price[C]]): Price[C] =
prices.select[Price[C]]
}
结果如下:
(Google)[https://google.com]
这是我目前的职能:
<a href="https://google.com">Google</a>
如果有人输入https://google.com,则会返回:
function MakeUrls($str)
{
$find=array('`((?:https?|ftp)://\S+[[:alnum:]]/?)`si','`((?<!//)(www\.\S+[[:alnum:]]/?))`si');
$replace=array('<a href="$1" target="_blank"> $0</a>', '<a href="http://$1" target="_blank">$1</a>');
return preg_replace($find,$replace,$str);
}
答案 0 :(得分:0)
function makeURLs($str) {
$explode = explode(")[", $str);
if (sizeof($explode) !== 2) return false; //failsafe stuff
$name = substr($explode[0], 1, strlen($explode[0])); //remove the (
$url = substr($explode[1], 0, strlen($explode[1])-1); //remove the ]
return "<a href=\"$url\" target=\"_blank\">$name</a>";
}
应该这样做