Hello my Friends i need ur help! :) Im an absolute beginner in swift and have absolutely no idea what i'm doing.
I need to extract all numbers from a txt file which i converted into a string. I want to save all the numbers into a new Array and i also have to use CharacterView to solve the problem.
This is what i got so far. Reading from the txt file is no problem.
func readFile(){
let path = Bundle.main.path(forResource: "paragraph", ofType: "txt")
var fileContents : String? = nil
do {
fileContents = try String(contentsOfFile: path!, encoding: String.Encoding.utf8)
} catch _ as NSError {
//ERROR HANDLING
}
print(fileContents)
}
this is the file:
§ 9 Lorem ipsum dolor (1) sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam. (2) Bed diam voluptua. At vero eos et accusam et justo duo 55 dolores et ea rebum. Stet clita kasd gubergren. (3) 1 abore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd.
Thank you for your time!