Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
こんにちは、ウェブサイトにユーザー生成コンテンツがいくつかあります。PHP関数を使用してリンクを削除したい。
たとえば、次の文字列があります。
"text1 http://link1 text2 www.link2 text3 link3.com text4"
http:、www.、.com を含む単語を検出し、テキストから削除する簡単な方法はありますか? または、リンクからテキストをきれいにする他の良い方法はありますか?
お時間をいただきありがとうございます!
$pattern = "/[a-zA-Z]*[:\/\/]*[A-Za-z0-9\-_]+\.+[A-Za-z0-9\.\/%&=\?\-_]+/i"; $replacement = ""; preg_replace($pattern, $replacement, $string);