Skip to Content
자바스크립트 완벽 가이드
book

자바스크립트 완벽 가이드

by David Flanagan, Han Seon- yong
February 2022
Beginner to intermediate
784 pages
24h 53m
Korean
Insight
Content preview from 자바스크립트 완벽 가이드
JavaScript
338
11장 자바스크립트 표준 라이브러리
//
직선인
따옴표를
이중
꺾쇠
(«)
로
교체하고
$1
에
저장된
텍스트는
바꾸지
않습니다
.
'He said "stop"'.replace(quote, '«$1»') //
=
> 'He said «stop»'
정규 표현식에서 이름 붙은 캡처 그룹을 사용한다면 숫자 대신 이름으로 텍스트를
참조할 수 있습니다.
let quote
=
/"(?<quotedText>[^"]*)"/g;
'He said "stop"'.replace(quote, '«$<quotedText>»') //
=
> 'He said «stop»'
두 번째 인자로 바꿀 문자열 대신 함수를 전달해 값을 반환하도록 해도 됩니다. 이
함수는 여러 가지 인자를 받으며 호출됩니다. 첫 번째는 일치하는 텍스트 전체입니
다. 정규 표현식에 캡처 그룹이 있으면 그룹에서 캡처한 부분 문자열이 인자로 전
달됩니다. 다음 인자는 문자열에서 일치하는 것을 찾은 위치입니다. 그다음에는
replace()
를 호출한 문자열 전체가 전달됩니다. 마지막으로, 정규 표현식에 이름
붙은 캡처 그룹이 있으면 마지막 인자는 프로퍼티 이름이 캡처 그룹 이름이고 값이
일치하는 텍스트인 객체입니다. 다음은 교체 함수를 써서 문자열에 있는 10진 정수
를 16진수로 변환합니다.
let s
=
"15 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

코드로 인프라 관리하기(2판)

코드로 인프라 관리하기(2판)

키프 모리스

Publisher Resources

ISBN: 9788966263462