看板 PHP 關於我們 聯絡資訊
請問各位一個問題 如果我有一串字串像是這樣 http://localhost/xxx/yyy 要怎麼做才能變成 <http://localhost/xxx/yyy> 這樣勒? 我之前嘗試過用 function _show_sparql_replace_str_1($urlStr) { $replace = '<'; $result = preg_replace('/^h/', $replace, $urlStr); return $result; } function _show_sparql_replace_str_2($urlStr) { $replace = '>'; $result = preg_replace('/$\s/', $replace, $urlStr); return $result; } 可是這兩個function似乎沒有作用 麻煩各位了 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.129.20.134
alpe:這, $str = "<$str>" ...不是比較快. 還是你要一篇文裡的url 07/16 21:17
PsMonkey:return "<".$urlStr.">"; (我真的不是來亂的) 07/16 21:17
PsMonkey:慢樓上一步 XD 07/16 21:18
alpe:preg_replace('/(http:\/\/.*?)[\s]/', "<\\1>")' 07/16 21:18
ycpeng0515:喔喔~~謝謝各位大大幫我突破盲點阿!!!! 07/16 21:21
see7di:看來是想太多了,最多就是用一下StriStr判斷有沒有罷了 07/16 21:45