π μ½λ©ν
μ€νΈ/Swift
[Swift] ReplacingOccurrences ( λ¬Έμμ΄ μΉν )
deep_lee
2023. 11. 2. 16:04
π λ¬Έμμ΄ λ΄ νΉμ λ¬Έμ λ³κ²½ (μΉν)
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"λ‘ λ³κ²½νλ μ½λμ΄λ€.