79569140

Date: 2025-04-11 15:02:14
Score: 0.5
Natty:
Report link

To Remove leading spaces from string

let exampleText = "   \n\tHello world !"
let regex = #/^\s*/# // regex finds any \s - symbols at the begging of the string
let textWithoutSpacesInLeading = exampleText.replacing(regexSa) { _ in "" } // replace 
textWithoutSpacesInLeading == "Hello world !" // true
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Daniel Smith