| 1 |
493ff79f
|
みぞ@CrazyBeatCoder
|
package com.mizo0203.timeline.talker;
|
| 2 |
df4ee0a0
|
みぞ@CrazyBeatCoder
|
|
| 3 |
|
|
import java.util.regex.Matcher;
|
| 4 |
|
|
import java.util.regex.Pattern;
|
| 5 |
|
|
|
| 6 |
|
|
/**
|
| 7 |
|
|
* http://chat-messenger.net/blog-entry-40.html
|
| 8 |
|
|
*/
|
| 9 |
|
|
public class UrlUtil {
|
| 10 |
|
|
/** URLを抽出するための正規表現パターン */
|
| 11 |
|
|
private static final Pattern convURLLinkPtn = Pattern.compile(
|
| 12 |
|
|
"(http://|https://){1}[\\w\\.\\-/:\\#\\?\\=\\&\\;\\%\\~\\+]+", Pattern.CASE_INSENSITIVE);
|
| 13 |
|
|
|
| 14 |
|
|
/**
|
| 15 |
|
|
* 指定された文字列内のURLを、正規表現を使用し、 空文字列に変換する。
|
| 16 |
|
|
*
|
| 17 |
|
|
* @param str 指定の文字列。
|
| 18 |
|
|
* @return リンクに変換された文字列。
|
| 19 |
|
|
*/
|
| 20 |
|
|
public static String convURLEmpty(CharSequence str) {
|
| 21 |
|
|
Matcher matcher = convURLLinkPtn.matcher(str);
|
| 22 |
|
|
return matcher.replaceAll("");
|
| 23 |
|
|
}
|
| 24 |
|
|
}
|