Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 실행
- round
- lowdb
- 자동
- 모듈
- nodemon
- 설치
- JavaScript
- 생활코딩
- Web
- Generator
- express
- template
- nodejs
- dr 학교측
- math
- 객체
- Web2
- Passport.js
- 객체정의
- sanitize
- app.js
- node.js
- local
- 객체란
- /bin/www
- tPerRow hn측
- passport
- 데이터
- 함수
Archives
- Today
- Total
괜찮아 잘하고있어 힘내
[JavaScript] 문자열 자르기 본문
참고:
https://sesok808.tistory.com/600
[JavaScript] 문자열 자르는 방법 (split, substr, substring)
자바스크립트 내에서 문자열을 자르는 방법에 대해 알아보자. 우선 문자열을 자르는 방법은 총 3가지로 split, substr, substring 이 존재한다. split함수 var a = "1,2,3" ; var array = a.split(","); ..
sesok808.tistory.com
split 함수
var test ="a,b,c,d";
var testArray = a.split(",");
설명: test변수 안에 있는 문자열을 "," 를 기준으로 testArray 변수에 testArray[0], testArray[1] ... 식으로 저장된다.
substr 함수
var test = "abcdefghijk";
var result = test.substr(2,5);
설명: substr(시작인덱스, 시작인덱스 부터의 길이) 형식이므로 결과는 cdefg 가 출력된다. 인덱스는 0부터 시작하기 때문에 c부터 출력된다.
substring 함수
var ates = "abcdefghijk"
var result = test.substring(2,5);
설명: substring(시작인덱스, 종료인덱스) 형식이므로 결과는 cdef 가 출력된다.
'웹 개발 > 개발 메모' 카테고리의 다른 글
[JavaScript] 글자 수 입력 제한 처리(바이트) (0) | 2021.08.11 |
---|---|
[asp.net] 페이지 include (0) | 2021.08.11 |
공부 (0) | 2021.08.11 |
[JavaScript] 소수점 올림, 버림, 반올림 (0) | 2021.08.11 |
varchar2 최대 크기로 설정(CLOB 타입으로 변경) (0) | 2021.08.11 |
Comments