Skip to main content
formatting
Source Link
clemens
  • 17.9k
  • 12
  • 52
  • 71

Swift 4.

let abc = "Hello world"

let result = abc.replacingOccurrences(of: " ", with: "_", options: NSString.CompareOptions.literal, range:nil)

print(result :(result))

//output =

let abc = "Hello world" let result = abc.replacingOccurrences(of: " ", with: "_", options: NSString.CompareOptions.literal, range:nil) print(result :\(result)) 

result Output: Hello_world

result : Hello_world 

Swift 4.

let abc = "Hello world"

let result = abc.replacingOccurrences(of: " ", with: "_", options: NSString.CompareOptions.literal, range:nil)

print(result :(result))

//output =

result : Hello_world

Swift 4:

let abc = "Hello world" let result = abc.replacingOccurrences(of: " ", with: "_", options: NSString.CompareOptions.literal, range:nil) print(result :\(result)) 

Output:

result : Hello_world 
Source Link
Manish
  • 184
  • 2
  • 9

Swift 4.

let abc = "Hello world"

let result = abc.replacingOccurrences(of: " ", with: "_", options: NSString.CompareOptions.literal, range:nil)

print(result :(result))

//output =

result : Hello_world