반응형

가끔 이런것이 필요할 때가 있다.

userId 를 USER_ID 로 바꾸는 기능.

  1. public class Test {
  2.     public static void main(String[] args) throws Exception {
  3.         String regex = "([a-z])([A-Z])";
  4.         String replacement = "$1_$2";
  5.                 String str = "UserId";
  6.                 String value = "";
  7.                 value = str.replaceAll(regex, replacement).toUpperCase();
  8.                 System.out.println(value);
  9.     }
  10. }

728x90
반응형

'Development > Java' 카테고리의 다른 글

Meta Annotaion  (0) 2013.07.01
Type-Safe Code란?  (0) 2013.06.25
Tomcat 구동시 라이브러리를 못찾을 경우..  (0) 2013.03.29
ExecutorService  (0) 2013.03.22
오버라이딩 규칙  (0) 2013.02.12

+ Recent posts