Untitled

mail@pastecode.io avatar
unknown
plain_text
25 days ago
707 B
2
Indexable
Never
import java.util.regex.Pattern;

public class KoreanTextChecker {

    public static boolean isKorean(String input) {
        // Regular expression pattern for Korean characters
        String koreanPattern = ".*[\\uAC00-\\uD7A3]+.*";
        
        // Compile the pattern
        Pattern pattern = Pattern.compile(koreanPattern);
        
        // Check if the input matches the pattern
        return pattern.matcher(input).matches();
    }

    public static void main(String[] args) {
        // Example usage
        String text1 = "안녕하세요";
        String text2 = "Hello";

        System.out.println(isKorean(text1)); // true
        System.out.println(isKorean(text2)); // false
    }
}
Leave a Comment