import Foundation
let pattern = #"(\d)(-\d*\.)"#
let regex = try! NSRegularExpression(pattern: pattern)
let testString = #"""
1 0.00000E+00-7.52896E-04 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 1.00247E-01 0.00000E+00
9 2.57945E+00-9.98377E-04 0.00000E+00 1.80923E+02 0.00000E+00 0.00000E+00 1.08995E+03 0.00000E+00 0.00000E+00 1.00795E+01 1.00002E-01 0.00000E+00
18 2.37285E+00-2.20000E-01 0.00000E+00 1.81079E+02-5.53001E+00 0.00000E+00 1.30827E+03 2.01207E+03 0.00000E+00 9.87285E+00 8.64615E-01 0.00000E+00
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let substitutionString = #"\1 \2"#
let result = regex.stringByReplacingMatches(in: testString, range: stringRange, withTemplate: substitutionString)
print(result)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Swift 5.2, please visit: https://developer.apple.com/documentation/foundation/nsregularexpression