문자열의 특정 부분을 지정된 길이만큼 반환하는 문제의 substr비교(오라클, ms sql, 자바, 자바스크립트, xplatform)
SI개발/XPlatform 2016. 1. 26. 16:15문제의 substr 때로는 substring이기도 하죠. 둘다 쓰기도 하고요. @_@;;
언어별로 혹은 DB별로 정리해보겠습니다. (오라클, Mssql, 자바, 자바스크립트, XPlatform)
1. Oracle
substr(char, postion, length) - length는 생략가능
SELECT SUBSTR('0123456789',2,3) FROM DUAL;
결과: 123
2. Ms Sql
SUBSTRING(expression ,start , length) - length를 생략할 경우 오류발생
SELECT SUBSTRING('0123456789',2,3)
결과: 123
3. Java
public String substring(int beginIndex)
public String substring(int beginIndex, int endIndex) - 두번째 인자가 길이가 아닌 '종료위치'임에 유의
"0123456789".substring(2,3)
결과: 2
4. JavaScript
(1) string.substr(start,length) - length는 생략가능
"0123456789".substr(2,3);
결과: 234
(2) string.substring(start, end) - end index는 생략가능
"0123456789".substring(2,3);
결과: 2
5. XPlatform
(1) String.substr(nStart [, nLength ]) - length는 생략가능
"0123456789".substr(2,3);
결과: 234
(2) String.substring(nStart, nEnd)
"0123456789".substring(2,3);
결과: 2
'SI개발 > XPlatform' 카테고리의 다른 글
[Xplatform][Miplatform] 그리드 체크박스 1개만 선택 (0) | 2017.06.18 |
---|---|
[XPlatform] 동적그리드 작성시 주의할점 (0) | 2016.01.19 |
[XPlatform] 엑셀 export시 셀서식이 맘대로 안될때 (0) | 2016.01.19 |
[XPlatform] getRowType에서 체크박스 칼럼은 제외하고 싶을때 (0) | 2016.01.19 |