How to remove leading zeros from a string in Swift

1 Answer

0 votes
import Foundation

var s = "0003429865.9301";

s = s.trimmingCharacters(in: CharacterSet(charactersIn: "0"))

print(s) 



/*
run:

3429865.9301

*/

 



answered Nov 15, 2024 by avibootz
...