πŸ“
til
  • TIL(Today I Learned)
  • javascript
    • value-number-string-boolean-null-undefined
    • primitive-reference
    • Hoisting
    • Prototypes in Javascript
    • this
    • prototype
    • μ½œλ°±ν•¨μˆ˜ (Callback function)
    • ν•¨μˆ˜μ˜ 호좜
    • 자료ꡬ쑰 new keyword
    • closure
    • Promise
    • event-loop
    • array-object
    • 객체
    • Arguments
    • higher order function
    • operators-function-control-flow
    • 객체 생성 νŒ¨ν„΄ 3κ°€μ§€
    • Javascript scopes
    • Functional Programming
    • Design Patterns
    • 데이터 νƒ€μž…
    • Object 객체
    • ν‘œμ€€ λ‚΄μž₯ 객체의 ν™•μž₯
    • μ°Έμ‘°
    • ν•¨μˆ˜
    • 상속(Inheritance)
    • this - 'this'λ₯Ό μ‚¬μš©ν•˜λŠ” ν•΄λ‹Ή ν•¨μˆ˜λ₯Ό 'μ–΄λ–»κ²Œ' μ‹€ν–‰ν•˜λŠλƒμ— λ”°λ₯Έ 4κ°€μ§€ this μ •μ˜
    • 전역객체(Global object)
    • 객체 μ§€ν–₯ ν”„λ‘œκ·Έλž˜λ°
    • The 'new' keyword - Object Creation in JavaScript
  • javascript-api
    • Number
      • Number.MAX_VALUE
      • Number.isInteger
      • Number.NEGATIVE_INFINITY
      • Number.isNaN()
      • Number.POSITIVE_INFINITY
      • Number.parseFloat
      • Number.EPSILON
      • number.toExponential
      • Number.MAX_SAFE_INTEGER
      • Number1 - μžμ—°μˆ˜, μ •μˆ˜, 10μ§„μˆ˜, 2μ§„μˆ˜, λΆ€λ™μ†Œμˆ˜μ , μ‹€μˆ˜
      • Number.isSafeInteger()
      • Number.MIN_VALUE
      • Number.parseInt
      • Number.NaN
      • Number.isFinite()
      • Number.MIN_SAFE_INTEGER
      • toFixed
    • string.split
    • String.fromCodePoint
    • string.trimEnd
    • string.padStart
    • string.@@iterator
    • String.fromCharCode
    • string.toUpperCase
    • string.codePointAt
    • string.toLowerCase()
    • string.toString
    • string.includes
    • string.replace()
    • string.charAt
    • String.lastIndexOf
    • string.slice
    • string.search
    • string.padEnd
    • string.substring
    • string.length
    • string.trim
    • string.localeCompare
    • String.indexOf
    • string.endsWith
    • string.valueOf
    • String.raw
    • string.matchAll()
    • string.repeat
    • string.match
    • String.prototype
    • string.startsWith
    • string.charCodeAt
    • string.trimStart
    • string.concat
    • string.toLocaleUpperCase()
    • string.toLocaleLowerCase
    • String
  • learn-node
    • debugger
    • Tip
  • schema-design
    • Database Schema Design
    • Database Schema Design
  • react
    • LifeCycle
    • redux
    • Context API
    • ν•¨μˆ˜ν˜• μ»΄ν¬λ„ŒνŠΈμ™€ 클래슀, μ–΄λ–€ 차이가 μ‘΄μž¬ν• κΉŒ?
    • Hooksκ³Ό useEffect μ‚¬μš©ν•΄ 보기
    • Route
    • async wait μ‚¬μš©ν•˜κΈ°
    • Hooks API Reference
    • context
    • npm uninstall ν•˜λŠ”λ²•
    • test λ§Œλ“€κΈ°
  • tip
    • ν΄λ¦°μ½”λ“œ
    • BxSlider둜 ν…μŠ€νŠΈ 흐λ₯΄λŠ” 효과 λ§Œλ“€κΈ°
  • javascript30
    • Event Capture, Propagation, Bubbling and Once
    • Object and Arrays - Reference VS Copy
  • typescript
    • μš°μ•„ν•œ νƒ€μž…μŠ€ν¬λ¦½νŠΈ 2λΆ€
    • The Basic Cheatsheet
    • TypeScript
    • Type Guards and Differnetiating Types
    • μš°μ•„ν•œ νƒ€μž…μŠ€ν¬λ¦½νŠΈ
    • Generics
  • git-from-the-hell
    • git
    • init-status-add-commit-log-stage-repository
    • log-diff
    • λ¨Έμ§€ ν›„ branch μ‚­μ œν•˜κΈ°
    • μ§€μ˜₯μ—μ„œ 온 Git
    • reset-revert
    • develop branch λ₯Ό pull ν•˜κ³  μ‹Άμ„λ•Œ
  • conference-and-seminar
    • λͺ¨λ˜ ν”„λ‘ νŠΈμ—”λ“œ κ°œλ°œν™˜κ²½μ˜ 이해
  • fire-base
    • Firebase .gitignore
  • vanillacoding
    • Data Structures
    • Sorting Algorithms - part 1
    • Promise
    • class
    • 04.quiz
    • 07.event-loop
    • Design Patterns
    • OOP (Object Oriented Programming)
  • etc
    • μ•Œκ³ λ¦¬μ¦˜ μ½”λ“œλ¦¬λ·°
    • 슀슀둜 κ³΅λΆ€ν•˜λŠ” 법
    • 바닐라코딩 μˆ˜κ°• ν›„κΈ°
    • async 과제 ν›„κΈ° - 비동기, 동기, ν΄λ‘œμ €, λ°°μ—΄κ³Ό 객체
    • μœ μš©ν•œ μ‚¬μ΄νŠΈ
  • algorithm
    • The Supermarket Queue
    • Find the odd int
    • The Office III - Broken Photocopier
    • Directions Reduction
    • The Office II - Boredom Score
    • Divisible Sum Pairs
    • Codewars 이용자 μ†”λ£¨μ…˜ λͺ¨μŒ
    • Shortest Word
    • find key
    • Two Sum
    • Simple Pig Latin
  • Book
    • the essence of object-orientation
      • νƒ€μž…κ³Ό 좔상화
      • 객체 지도
      • μ΄μƒν•œ λ‚˜λΌμ˜ 객체
      • 좔상화 기법
      • 05. μ±…μž„κ³Ό λ©”μ‹œμ§€
      • 07.ν•¨κ»˜ λͺ¨μœΌκΈ°
      • 04. μ—­ν• , μ±…μž„, ν˜‘λ ₯
      • ν˜‘λ ₯ν•˜λŠ” κ°μ²΄λ“€μ˜ 곡동체
  • ecma-script2015
    • Object Literal Upgrades
    • default-parameter-template-literals-arrow-functions
    • spread-operator-rest-param
    • let-const-rest-parameter-spread-operator-destructuring
  • http
    • μ›Ή λΈŒλΌμš°μ €μ— URL을 μž…λ ₯ν–ˆμ„ λ•Œ μ–΄λ–»κ²Œ μ›Ή νŽ˜μ΄μ§€κ°€ λ³΄μ—¬μ§ˆκΉŒ?
  • jest
    • toThrow(error?)
  • data-structures
    • Data Structures
  • express
    • express generator
    • CORS
  • css-flexible-box-layout
    • flex 해버렸지 뭐야
  • git
    • Git
  • mongodb
    • MongoDB
  • markdown
    • use-markdown
  • cmder
    • cmd λͺ…λ Ήμ–΄ λͺ¨μŒ
  • debug
    • trackClicksEx function error
  • npm
    • NPM TOKEN μ„€μ •ν•˜κΈ°
  • storybook
    • Storybook
  • sort
    • Sorting Algorithms - part 1
  • javascript-koans
    • Javascript Koans μ˜€λ‹΅λ…ΈνŠΈ
  • rxjs
    • Rx.js
  • dom-elements
    • HTML Element
  • redux-toolkit
    • Redux Toolkit
  • github-actions
    • GitHub Actions
  • redux-middleware
    • redux middleware
  • rest
    • rest
  • css-rendering
    • μ½”λ“œ μŠ€ν”ΌμΈ  - CSS Rendering 1회차 2/2
    • μ½”λ“œ μŠ€ν”ΌμΈ  - CSS Rendering 1회차 1/2
  • you-dont-know-js
    • νƒ€μž…
  • server
    • # shutdown local server
  • semantic-versioning
    • Semantic Versioning 2.0.0
Powered by GitBook
On this page
  • Syntax
  • Parameters
  • Return value
  • Description
  • Examples
  • split() μ‚¬μš©
  • λ¬Έμžμ—΄μ— 곡백 μ œκ±°ν•˜κΈ°
  • μ œν•œλœ 수의 λΆ„ν•  κ²°κ³Όλ₯Ό λ°˜ν™˜
  • RegExpλ₯Ό μ‚¬μš©ν•΄ κ΅¬λΆ„μžλ„ 결과에 ν¬ν•¨ν•˜κΈ°
  • split()으둜 λ¬Έμžμ—΄ λ’€μ§‘κΈ°

Was this helpful?

  1. javascript-api

string.split

PrevioustoFixedNextString.fromCodePoint

Last updated 5 years ago

Was this helpful?

split() λ©”μ„œλ“œλŠ” λ¬Έμžμ—΄μ„ μ •λ ¬λœ ν•˜μœ„ λ¬Έμžμ—΄ μ§‘ν•©μœΌλ‘œ λ‚˜λˆ„κ³  μ΄λŸ¬ν•œ ν•˜μœ„ λ¬Έμžμ—΄μ„ λ°°μ—΄λ‘œ 넣은 λ‹€μŒ 배열을 λ°˜ν™˜ν•œλ‹€. 뢄할은 νŒ¨ν„΄μ„ κ²€μƒ‰ν•˜μ—¬ μˆ˜ν–‰ν•œλ‹€. μ—¬κΈ°μ„œ νŒ¨ν„΄μ€ λ©”μ„œλ“œμ˜ ν˜ΈμΆœμ—μ„œ 첫번째 λ§€κ°œλ³€μˆ˜λ‘œ μ œκ³΅λœλ‹€.

const str = 'A cat playing with a mouse.';
const words = str.split(' '); // ["A", "cat", "playing", "with", "a", "mouse."];
const strCopy = str.split(); // ["A cat playing with a mouse."]

Syntax

str.split([separator[, limit]])

Parameters

separator (Optional)

각 뢄할이 λ°œμƒν•˜λŠ” μœ„μΉ˜λ₯Ό λ‚˜νƒ€λ‚΄λŠ” νŒ¨ν„΄μ΄λ‹€. separator λŠ” λ‹¨μˆœν•œ λ¬Έμžμ—΄μ΄ 될 수 있고 μ •κ·œν‘œν˜„μ‹μ΄ 될 수 μžˆλ‹€.

  • κ°€μž₯ κ°„λ‹¨ν•œ κ²½μš°λŠ” separator κ°€ 단일 문자일 λ•Œ 이닀. κ΅¬λΆ„λœ λ¬Έμžμ—΄μ„ λΆ„ν• ν•˜λŠ”λ° μ‚¬μš©λœλ‹€. 예λ₯Ό λ“€μ–΄ νƒ­ ꡬ뢄 κ°’ (TSV)을 ν¬ν•¨ν•˜λŠ” λ¬Έμžμ—΄μ€ λ‹€μŒκ³Ό 같이 νƒ­ 문자λ₯Ό ꡬ뢄 기호둜 μ „λ‹¬ν•˜μ—¬ ꡬ문을 뢄석할 수 μžˆλ‹€. myString.split("\t")

  • separator κ°€ λ‘κΈ€μž 이상일 경우, λΆ„ν• ν•˜λ €λ©΄ ν•΄λ‹Ή 전체 λ¬Έμžμ™€ μΌμΉ˜ν•˜μ—¬μ•Ό ν•œλ‹€.

  • separator κ°€ μƒλž΅λ˜κ±°λ‚˜ strμ—μ„œ μ—†λŠ” λ¬Έμžμ—΄μΌ 경우, 전체 λ¬Έμžμ—΄λ‘œ κ΅¬μ„±λœ ν•˜λ‚˜μ˜ μš”μ†Œλ§Œμ΄ μžˆλŠ” 배열을 λ°˜ν™˜ν•œλ‹€.

  • separator κ°€ λ¬Έμžμ—΄μ˜ μ‹œμž‘μ΄λ‚˜ λμ§€μ μœΌλ‘œ λ‚˜νƒ€λ‚˜λ„ μ—¬μ „νžˆ λΆ„ν• μ˜ νš¨κ³Όκ°€ μžˆλ‹€. κ²°κ³ΌλŠ” λ°˜ν™˜λœ λ°°μ—΄μ˜ 첫번째 μœ„μΉ˜(ν˜Ήμ€ λ§ˆμ§€λ§‰)μ—λŠ” 빈 λ¬Έμžμ—΄μ΄λ‹€.

  • separator κ°€ 빈 λ¬Έμžμ—΄μΈ 경우, str은 각각의 UTF-16 문자의 λ°°μ—΄λ‘œ λ³€ν™˜λœλ‹€.

주의: separatorκ°€ 빈 λ¬Έμžμ—΄("")둜 제곡되면, μ‚¬μš©μžκ°€ μΈμ‹ν•˜λŠ” 문자 ν•˜λ‚˜(grapheme cluster)λ˜λŠ” μœ λ‹ˆμ½”λ“œ 문자(μ½”λ“œν¬μΈνŠΈ) ν•˜λ‚˜μ”©μœΌλ‘œ λ‚˜λˆ„λŠ” 것이 μ•„λ‹ˆλΌ, UTF-16 μ½”λ“œ μœ λ‹›μœΌλ‘œ λ‚˜λˆ„κ²Œ 되며 surrogate pairκ°€ λ§κ°€μ§ˆ 수 μžˆλ‹€. μŠ€νƒ μ˜€λ²„ν”Œλ‘œμš°μ˜ λ₯Ό μ°Έκ³ ν•˜μž.

UTF-16 μ½”λ“œ μœ λ‹›μ΄ μ•„λ‹Œ μœ λ‹ˆμ½”λ“œ 문자(μ½”λ“œν¬μΈνŠΈ) ν•˜λ‚˜μ”© λ‚˜λˆ„λŠ” surrogate pairκ°€ 망가지지 μ•Šκ³  λΆ„ν• ν•˜λŠ” 방법

  1. Spread syntax μ‚¬μš©

    [...'πŸ˜πŸ™πŸšπŸ›']; // ["𝟘", "πŸ™", "𝟚", "πŸ›"]
  2. Array.form

    Array.from('πŸ˜πŸ™πŸšπŸ›'); // ["𝟘", "πŸ™", "𝟚", "πŸ›"]
  3. string.prototype.split() 와 RegExp u flag μ‚¬μš©ν•˜κΈ°

    'πŸ˜πŸ™πŸšπŸ›'.split(/(?=[\s\S])/u); // ["𝟘", "πŸ™", "𝟚", "πŸ›"]

limit (Optional)

음이 μ•„λ‹Œ μ •μˆ˜λ‘œ λ‚˜λˆŒ 수λ₯Ό μ œν•œν•œλ‹€. 이 λ§€κ°œλ³€μˆ˜κ°€ 제곡되면 separator κ°€ λ“±μž₯ν•  λ•Œλ§ˆλ‹€ λ¬Έμžμ—΄μ„ λŠμ§€λ§Œ λ°°μ—΄μ˜ μ›μ†Œκ°€ limitκ°œκ°€ 되면 λ©ˆμΆ˜λ‹€. 남은 ν…μŠ€νŠΈλŠ” 배열에 ν¬ν•¨λ˜μ§€ μ•ŠλŠ”λ‹€.

  • limit 에 λ„λ‹¬ν•˜κΈ° 전에 λ¬Έμžμ—΄ 끝에 λ„λ‹¬ν•˜λ©΄ λ°°μ—΄μ—λŠ” μ œν•œλ³΄λ‹€ 적은 미만의 μ›μ†Œκ°€ μžˆμ„ μˆ˜λ„ μžˆλ‹€.

  • λ§Œμ•½ limit λŠ” 1 이면 [str] 이 λ°˜ν™˜λœλ‹€.

  • λ§Œμ•½ limit λŠ” 0 이면 [] 이 λ°˜ν™˜λœλ‹€.

Return value

λ¬Έμžμ—΄μ΄ μ›μ†Œλ‘œ 이루어진 Array둜, μ£Όμ–΄μ§„ λ¬Έμžμ—΄μ΄ spearator 포인트둜 λΆ„ν• λœ 것이닀.

Description

separatorκ°€ λ°œκ²¬λμ„ λ•Œ λ¬Έμžμ—΄μ€ μ‚­μ œλ˜κ³ , 남은 λ¬Έμžμ—΄μ€ λ°°μ—΄λ‘œ λ°˜ν™˜λœλ‹€. λ§Œμ•½ separator κ°€ ν¬νšκ΄„ν˜Έ(capturing parentheses)λ₯Ό ν¬ν•¨ν•˜λŠ” μ •κ·œμ‹μΌ 경우, separator κ°€ μΌμΉ˜ν•  λ•Œ λ§ˆλ‹€ 포획 κ΄„ν˜Έμ˜ (μ •μ˜λ˜μ§€ μ•Šμ€ κ²½μš°λ„ ν¬ν•¨ν•˜μ—¬) κ²°κ³Όκ°€ λ°°μ—΄μ˜ ν•΄λ‹Ή μœ„μΉ˜μ— ν¬ν•¨λœλ‹€.

separatorκ°€ 배열인 경우, ν•΄λ‹Ή 배열은 λ¬Έμžμ—΄λ‘œ κ°•μ œ λ³€ν™˜λ˜μ–΄ sperator둜 μ‚¬μš©λœλ‹€.

Examples

split() μ‚¬μš©

λ¬Έμžμ—΄μ΄ λΉ„μ˜€μ„ λ•Œ split()λŠ” ν•˜λ‚˜μ˜ 빈 λ¬Έμžμ—΄μ„ ν¬ν•¨ν•œ 배열을 λ°˜ν™˜ν•œλ‹€. (빈 배열이 μ•„λ‹ˆλ‹€.) λ§Œμ•½ separatorκ³Ό λ¬Έμžμ—΄μ΄ λ‘˜ λ‹€ 빈 λ¬Έμžμ—΄μ΄λΌλ©΄ 빈 배열을 λ°˜ν™˜ν•œλ‹€.

const myString = '';
myString.split(); // [""]
myString.split(''); // []

λ‹€μŒ μ˜ˆμ œλŠ” λ¬Έμžμ—΄μ„ μ£Όμ–΄μ§„ separator둜 λŠλŠ” ν•¨μˆ˜λ₯Ό μ •μ˜ν•œλ‹€. λ¬Έμžμ—΄μ„ λŠμ€ λ‹€μŒμ—λŠ” (끊기 μ΄μ „μ˜) 원본 λ¬Έμžμ—΄κ³Ό μ‚¬μš©ν•œ separator, λ°°μ—΄μ˜ 길이와 μ›μ†Œλ₯Ό log둜 좜λ ₯ν•œλ‹€.

function splitString(stringToSplit, separator) {
  const arrayOfStrings = stringToSplit.split(separator);

  console.log('원본 λ¬Έμžμ—΄: ', stringToSplit);
  console.log('separator: ', separator);
  console.log('array: ', arrayOfStrings.length, 'elements: ', arrayOfStrings.join(' / '))
}

const wikiString = 'A cat playing with a mouse.';
const monthString = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec';

const space = ' ';
const comma = ',';

splitString(wikiString, space);
splitString(wikiString);
splitString(monthString, comma);

log ν™•μΈν•˜κΈ°

// splitString(wikiString, space);
원본 λ¬Έμžμ—΄:  A cat playing with a mouse.
separator: 
array:  6 elements:  A / cat / playing / with / a / mouse.

// splitString(wikiString);
원본 λ¬Έμžμ—΄:  A cat playing with a mouse.
separator:  undefined
array:  1 elements:  A cat playing with a mouse.

// splitString(monthString, comma);
원본 λ¬Έμžμ—΄:  Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec
separator:  ,
array:  12 elements:  Jan / Feb / Mar / Apr / May / Jun / Jul / Aug / Sep / Oct / Nov / Dec

λ¬Έμžμ—΄μ— 곡백 μ œκ±°ν•˜κΈ°

λ‹€μŒ μ˜ˆμ œλŠ” split()은 0개 μ΄μƒμ˜ 곡백을 μ°Ύκ³ , κ·Έ λ‹€μŒμ΄ μ„Έλ―Έμ½œλ‘ μ΄κ³ , κ·Έ λ‹€μŒμ΄ 0개 μ΄μƒμ˜ 곡백을 μ°Ύμ•„λ‚΄κ³ , 찾으면 λ¬Έμžμ—΄μ—μ„œ 곡백과 μ„Έλ―Έμ½œλ‘ μ„ μ œκ±°ν•œλ‹€. -> μ„Έλ―Έμ½œλ‘ μ˜ μ•žλ’€μ˜ 곡백을 μ°Ύκ³  곡백과 μ„Έλ―Έμ½œλ‘ μ„ μ œκ±°ν•œλ‹€.

const names = 'harry Trump ;Fred Barney; helen Rigby ; Bill Abel ; Chris Hand ';

console.log(names);

const re = /\s*(?:;|$)\s*/
const nameList = names.split(re); // harry Trump ;Fred Barney; helen Rigby ; Bill Abel ; Chris Hand 

console.log(nameList); // ["harry Trump", "Fred Barney", "helen Rigby", "Bill Abel", "Chris Hand", ""]

μ œν•œλœ 수의 λΆ„ν•  κ²°κ³Όλ₯Ό λ°˜ν™˜

이 μ˜ˆμ œλŠ” split()은 λ¬Έμžμ—΄μ—μ„œ 곡백을 μ°Ύκ³ , 발견된 졜초의 3개의 λΆ„ν•  κ²°κ³Όλ₯Ό λ°˜ν™˜ν•œλ‹€.

const myString = 'A cat playing with a mouse.';
myString.split(' ', 3); // ["A", "cat", "playing"]

RegExpλ₯Ό μ‚¬μš©ν•΄ κ΅¬λΆ„μžλ„ 결과에 ν¬ν•¨ν•˜κΈ°

separatorκ°€ 캑쳐링 κ΄„ν˜Έ() λ₯Ό ν¬ν•¨ν•˜λŠ” μ •κ·œν‘œν˜„μ‹μΌ 경우, 캑쳐링된 결과도 배열에 ν¬ν•¨λœλ‹€.

const mySting = 'Hello 1 word. Sentence number 2.';
// 캑쳐링을 μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” 경우
myString.split(/\d/); // ["Hello ", " word. Sentence number ", "."] 숫자 뢀뢄을 μ°Ύμ•„λ‚΄ 제거되고 λΆ„ν• λ˜μ—ˆλ‹€.

// 캑쳐링을 μ‚¬μš©ν•œ 경우
myString.split(/(\d)/); // ["Hello ", "1", " word. Sentence number ", "2", "."] μˆ«μžλΆ€λΆ„λ„ 같이 ν¬ν•¨λ˜μ—ˆλ‹€.

\d λŠ” character classμ—μ„œ 0λΆ€ν„° 9μ‚¬μ΄μ˜ μˆ˜μ™€ μΌμΉ˜ν•œλ‹€.

split()으둜 λ¬Έμžμ—΄ λ’€μ§‘κΈ°

const str = 'asdfghjk1';
str.split('').reverse().join(''); // "1kjhgfdsa"
// split()μ—μ„œ λ°˜ν™˜ν•˜λŠ” λ°°μ—΄μ—λŠ” reverse()와 join()을 μ‚¬μš©ν•  수 μžˆλ‹€.

이 방법은 λ¬Έμžμ—΄ 뒀집기에 효과적인 방법이 μ•„λ‹ˆλ‹€.

λ¬Έμžμ—΄μ— grapheme clustersκ°€ μžˆμ„ 경우, μœ λ‹ˆμ½”λ“œ ν”Œλž˜κ·Έλ₯Ό 섀정해도 였λ₯˜λ₯Ό μΌμœΌν‚΅λ‹ˆλ‹€.

(esrever λ“±μ˜ 라이브러리λ₯Ό λŒ€μ‹  μ‚¬μš©ν•˜λΌ)

const str = 'rΓ©sumΓ©';
str.split(/(?:)/u).reverse().join(''); // "Γ©musΓ©r"

=== λ₯Ό μ‚¬μš©ν•˜λ©΄ palindrome(μ•žμ—μ„œ λΆ€ν„° μ½μœΌλ‚˜ λ’€μ—μ„œ λΆ€ν„° μ½μœΌλ‚˜ λ™μΌν•œ 단어)인지 확인할 수 μžˆλ‹€.

u flagλŠ” μœ λ‹ˆμ½”λ“œ; νŒ¨ν„΄μ„ μœ λ‹ˆμ½”λ“œ μ½”λ“œ 포인트의 λ‚˜μ—΄λ‘œ μ·¨κΈ‰ν•œλ‹€. /(?=.)/u λŒ€μ‹ μ— /(?=[\s\S])/u λ₯Ό μ‚¬μš©ν•œ 이유 .

How do you get a string to a character array in JavaScript?
How to use JavaScript regex over multiple lines?