• 회원가입
  • 로그인
  • 구글아이디로 로그인

[RegExp] JS - toString() 메서드 - 정규표현식의 문자열을 반환 (= toString메서드 = 투스트링메서드)

목차
  1. toString() 예제 - 정규표현식의 문자열 값 반환
  2. toString() 정의
  3. toString() 구문

 

toString() 예제 - 정규표현식의 문자열 값 반환

[예제1]

 

<p id="demo"></p>


<script>

let pattern = new RegExp("Homzzang.com", "g");

let text = pattern.toString();


document.getElementById("demo").innerHTML = text;

</script>

 

결과보기 (결과값: https://homzzang.com/g)


[예제2]

 

<p id="demo"></p>


<script>

let pattern = /Homzzang.com/g;

let text = pattern.toString();


document.getElementById("demo").innerHTML = text;

</script>

 

결과보기 (결과값: https://homzzang.com/g)

 

toString() 정의

 

정규표현식의 문자열 값을 반환.

 


 

  • ECMAScript1(ES1, JavaScript 1997)
  • 모든 브라우저 지원.

 

 

toString() 구문

 

RegExpObject.toString()

 


[매개변수]

 

없음.

 


[반환값]

 

정규표현식의 문자열 값을 반환.

※ 값 타입: String

 

 


분류 제목
DOM_Attribute JS - attr.isId -
DOM_Attribute JS - attr.name -
DOM_Attribute JS - attr.value -
DOM_Attribute JS - attr.specified -
DOM_Attribute JS - nodemap.getNamedItem() 메서드 -
DOM_Attribute JS - nodemap.item() 메서드 -
DOM_Attribute JS - nodemap.length -
DOM_Attribute JS - nodemap.removeNamedItem() 메서드 -
DOM_Attribute JS - nodemap.setNamedItem() 메서드 -
Window_Console JS - console.assert() 메서드 - 표현식이 FALSE인지 확인 (= 표현식 거짓 여부 체크 …
Window_Console JS - console.clear() 메서드 - 콘솔 지우기 (=콘솔창 청소 = console.clear메…
Window_Console JS - console.count() 메서드 - 콘솔창에서 카운트하기 (= 숫자 세기 = console.co…
Window_Console JS - console.error() 메서드 - 콘솔창에서 에러메시지 띄우기 (= console.error메…
Window_Console JS - console.group() 메서드 - 콘솔에서 메시지 그룹 생성 시작 (= console.grou…
Window_Console JS - console.groupCollapsed() 메서드 - 콘솔에서 접힌/축소된 메시지 그룹 시작 지정…
Window_Console JS - console.groupEnd() - 메시지 그룹의 끝/종료 지점 지정 (= console.grou…
Window_Console JS - console.info() 메서드 - 콘솔에 메시지 쓰기 (= console.info메서드 = 콘솔…
Window_Console JS - console.log() 메서드 - 콘솔에 메시지 쓰기 (= console.log메서드 = 콘솔로그…
Window_Console JS - console.table() 메서드 - 콘솔에 테이블 쓰기 (= console.table메서드 = …
Window_Console JS - console.time() 메서드 - 콘솔창에서 타이머 시작 (= console.time메서드 = …
23/67
목록
찾아주셔서 감사합니다. Since 2012