Last active
October 11, 2020 07:22
Removes text between 2 delimiters.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
(TextToClean as text, StartDelimiter as text, EndDelimiter as text, optional RemoveDelimiters) => | |
let | |
removeDelimiters = if RemoveDelimiters = null then StartDelimiter & EndDelimiter else "", | |
Source = Text.From(TextToClean), | |
FirstSplit = List.Buffer( Text.Split(Source, StartDelimiter) ), | |
Custom2 = if List.First(FirstSplit) = "" then List.Skip(FirstSplit) else FirstSplit, | |
Custom1 = List.Transform(Custom2, each if Text.Contains(_, EndDelimiter) then Text.AfterDelimiter(_, EndDelimiter, 0) else _), | |
ListSelect = List.Select(Custom1, each _<>""), | |
TextCombine = Text.Combine(ListSelect, removeDelimiters) | |
in | |
TextCombine, | |
documentation = [ | |
Documentation.Name = " Text.RemoveBetweenDelimiters ", | |
Documentation.Description = " Removes text between 2 delimiters. ", | |
Documentation.LongDescription = " Removes text between 2 delimiters. Option to remove the delimiters as well. Delimters are strings, so can contain multiple characters. ", | |
Documentation.Category = " Text ", | |
Documentation.Source = " www.TheBIccountant.com . https://wp.me/p6lgsG-2ak . ", | |
Documentation.Version = " 2.0 ", | |
Documentation.Author = " Imke Feldmann: www.TheBIccountant.com. https://wp.me/p6lgsG-2ak . ", | |
Documentation.Examples = {[Description = " ", | |
Code = " ", | |
Result = " "]}] | |
in | |
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adjusted for repeating split characters