let ExcelTrim = (TextToTrim, str) => let ReplacedText = Text.Replace(TextToTrim, str,""), Result = if not (Text.Contains(ReplacedText, str)) then ReplacedText else @ExcelTrim(ReplacedText) in Text.Trim(Result) in ExcelTrim