티스토리 뷰

regular expression's syntax를 사용하여 대소문자 구분없이 String을 replace하기

예1) "test"란 Text을 Real로 replace

String argStr = "this is Test!. this is test.";
argStr = argStr.replaceAll("(?i:test)", "Real");

==> this is Real!. this is Real.


예2) "test" 또는 "test!" 란 Text을 Real로 replace

String argStr = "this is Test!. this is test.";
argStr = argStr.replaceAll("(?i:test!?)", "Real");

==> this is Real. this is Real. 

'Language > JSP' 카테고리의 다른 글

문자치환  (0) 2015.11.29
대문자 소문자 변경  (0) 2015.11.29
파일 확장자 구하기  (0) 2015.11.29
JDBC, 커넥션풀  (0) 2015.11.29
날짜비교  (0) 2015.11.29
Total
Today
Yesterday
최근에 올라온 글
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31