๐ ๋ฌธ์์ด ๋ด ํน์ ๋ฌธ์ ๋ณ๊ฒฝ (์นํ)
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"๋ก ๋ณ๊ฒฝํ๋ ์ฝ๋์ด๋ค.
'๐ ์ฝ๋ฉํ ์คํธ > Swift' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Swift] enumerated ( ๋ฐฐ์ด์ index ๊ฐ ) (0) | 2023.11.14 |
---|---|
[Swift] ์ Swift์์ ๋ฌธ์์ด์ index๋ก ์กฐํํ์ง ๋ชปํ ๊น? (0) | 2023.11.08 |
[Swift] Split , Components (0) | 2023.11.02 |
[Swift] Map, Filter, Reduce (1) | 2023.11.01 |
[Swift] prefix suffix (0) | 2023.11.01 |