LoginSignup
3
4

More than 5 years have passed since last update.

Javaで手軽に正規表現を使うスニペット

Last updated at Posted at 2016-01-27

ほとんど備忘録です。LLだとけっこう手軽にできるんでいざJavaで手軽にやろうとすると迷うことがあります。

Javaはいつもなんとなく書くだけのことが多いので、
詳しい人おかしいところあったら指摘してもらえると嬉しいです。

パータンにマッチしているかどうかを判定


    /**
     * 正規表現
     * @param str
     * @param regex
     * @return
     */
    public static boolean isMatch(String str,String regex){
        return  regex!= null && str != null && str.matches(regex);
    }

※String.matchesを使うのがよいとコメントを頂き修正しました。感謝です。

3
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4