Skip to content

Instantly share code, notes, and snippets.

@bi119aTe5hXk
Last active February 8, 2021 00:58
Show Gist options
  • Save bi119aTe5hXk/17da12638ba086cc5c815d9526978eae to your computer and use it in GitHub Desktop.
Save bi119aTe5hXk/17da12638ba086cc5c815d9526978eae to your computer and use it in GitHub Desktop.
Replace texts using swift playground
import Cocoa
import PlaygroundSupport
let path = Bundle.main.path(forResource: "api", ofType: "html")
var htmlString = try? String(contentsOfFile: path!, encoding: .utf8)
//print(htmlString)
//public let replaceTexts = ["org text": "replaced text"]
for _ in 1...100 {
for (key,value) in replaceTexts {
htmlString = htmlString!.replacingOccurrences(of: key, with: value)
}
}
print(htmlString!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment