Deep_Dev
article thumbnail

๐Ÿ“š ๋ฌธ์ž์—ด ๋‚ด ํŠน์ •๋ฌธ์ž ๋ณ€๊ฒฝ (์น˜ํ™˜)

 

 

 

 

 

ReplacingOccurrences

๋ฌธ์ž์—ด์„ ๋Œ€์ฒดํ•˜์—ฌ ์ƒˆ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

 

- of target : ๋ฐ”๊ฟ€ ๋ฌธ์ž์—ด

- with replacement : ๋Œ€์ฒดํ•  ๋ฌธ์ž์—ด

 

 

์‚ฌ์šฉ์˜ˆ์‹œ

let str = "Bye Nice to meet you"
let result = str.replacingOccurrences(of: "Bye", with: "Hello")
print(result) // "Hello Nice to meet you"

 

of: ์— ์žˆ๋Š” "Bye"๋ฅผ "Hello"๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ์ฝ”๋“œ์ด๋‹ค.