プロジェクト

全般

プロフィール

ダウンロード (861 Bytes) 統計
| ブランチ: | タグ: | リビジョン:

github / src / com / mizo0203 / timeline / talker / util / UrlUtil.java @ 6a3fcb6d

1
package com.mizo0203.timeline.talker.util;
2

    
3
import org.jetbrains.annotations.NotNull;
4

    
5
import java.util.regex.Matcher;
6
import java.util.regex.Pattern;
7

    
8
/** http://chat-messenger.net/blog-entry-40.html */
9
public class UrlUtil {
10
  /** URLを抽出するための正規表現パターン */
11
  @SuppressWarnings("Annotator")
12
  private static final Pattern convURLLinkPtn =
13
      Pattern.compile(
14
          "(http://|https://){1}[\\w\\.\\-/:\\#\\?\\=\\&\\;\\%\\~\\+]+", Pattern.CASE_INSENSITIVE);
15

    
16
  /**
17
   * 指定された文字列内のURLを、正規表現を使用し、 空文字列に変換する。
18
   *
19
   * @param str 指定の文字列。
20
   * @return リンクに変換された文字列。
21
   */
22
  public static String convURLEmpty(@NotNull CharSequence str) {
23
    Matcher matcher = convURLLinkPtn.matcher(str);
24
    return matcher.replaceAll("");
25
  }
26
}
(4-4/4)