public static boolean isPunct ( String s ) { Pattern p = Pattern . compile ( "^[\\p{Punct}]+$" ) ; Matcher m = p . matcher ( s ) ; return m . matches ( ) ; }
Given a String the method uses Regex to check if the String only contains punctuation characters