상세 컨텐츠

본문 제목

replace

프로그래밍/Java

by ........? 2012. 5. 22. 13:45

본문

StringBuffer 클래스

public StringBuffer replace(int start,int end, String str)
start
- The beginning index, inclusive.
end
- The ending index, exclusive.
str
- String that will replace previous contents.

info/insletter/boardDetail.jsp 에서

bf_source.replace(1, 6, "?");

시작위치,끝위치,대신 넣을 문자


1부터 6 앞까지의 문자(즉 인덱스1부터 인덱스5까지)를 "?" 로 대체해라



String 클래스

var str = "aaa\nbbb\nccc\n";

str.replace("\n", " " );

aaa bbb
ccc

replace 는 문자 한번만 치환 해준다 한다

한문자가 아닌 경우에는 패턴을 잡아 줘야 한다

str .replace(/\n+/g, " ");

'프로그래밍 > Java' 카테고리의 다른 글

== 와 equals 와 equalsIgnoreCase 차이  (0) 2012.06.18
Hashtable  (0) 2012.05.22
resonse.sendRedirect() & forward  (0) 2012.05.22
Static 변수  (0) 2012.05.16
split & StringTokenizer  (0) 2012.05.15

관련글 더보기

댓글 영역