Notice
Recent Posts
Recent Comments
Link
목록숫자 제거 (1)
SeouliteLab
[Java/자바] 문자열에서 특수문자 제거, 숫자 제거, 숫자만 남기기
예제 1: 특수문자 제거 String str = "Hello, World! This is a test string."; String result = str.replaceAll("[^a-zA-Z0-9]", ""); System.out.println(result); // 출력 결과: HelloWorldThisisateststring 정규 표현식을 사용하여 문자열에서 특수문자를 제거하는 예제입니다. `replaceAll` 메서드를 사용하여 대상 문자열에서 알파벳과 숫자가 아닌 모든 문자를 제거합니다. 예제 2: 숫자 제거 String str = "The price is $9.99"; String result = str.replaceAll("\\d", ""); System.out.println(result); ..
프로그래밍
2024. 3. 8. 09:05