{"title":"Text.DelStr(Text, Integer [, Integer]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/text/text-delstr-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-delstr-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-delstr-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Deletes a substring inside a string (text or code).","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Text.DelStr(Text, Integer [, Integer]) Method","slug":"textdelstrtext-integer-integer-method","at":0,"chars":1982},{"level":2,"title":"Syntax","slug":"syntax","at":160,"chars":175},{"level":2,"title":"Parameters","slug":"parameters","at":335,"chars":428},{"level":2,"title":"Return Value","slug":"return-value","at":763,"chars":97},{"level":2,"title":"Remarks","slug":"remarks","at":860,"chars":294},{"level":2,"title":"Example","slug":"example","at":1154,"chars":696},{"level":2,"title":"Related information","slug":"related-information","at":1850,"chars":132}],"text":"# Text.DelStr(Text, Integer [, Integer]) Method\n> Version: _Available or changed with runtime version 1.0._\nDeletes a substring inside a string (text or code).\n## Syntax\n```al\nNewString :=   Text.DelStr(String: Text, Position: Integer [, Length: Integer])\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nString\nType: text-data-type\nThe input string.\nPosition\nType: ../integer/integer-data-type\nThe position of the first character that you want to delete. Position must be greater than zero (0). If Position exceeds the length of String, DELSTR returns the original string, unchanged.\n*[Optional] Length*\nType: ../integer/integer-data-type\nSpecifies how many characters to delete. Length must be greater than zero (0).\n## Return Value\nNewString\nType: text-data-type\nThe input string without the specified substring.\n## Remarks\nIf you omit Length, all the characters starting with Position are deleted until the end of the string.\nIf you omit Length and Position is less than 1, then an error is returned.\nIf you omit Length and Position is greater than the length of String, then String is returned unchanged.\n## Example\n```al\nvar\n    Str: Text[40];\n    NewStr: Text[40];\n    Position: Integer;\n    Length: Integer;\n    Text000: TexConst ENU='Adjusting prices - Please wait.';\n    Text001: TexConst ENU='The original string:>%1<';\n    Text002: TexConst ENU='The original modified:>%2<';\nbegin\n    Str := Text000;\n    Position := 11; // Remove the word 'prices' and a blank.\n    Length := 7;\n    NewStr := DelStr(Str, Position, Length);\n    Message(Text001, Str);\n    Message(Text002, NewStr);\nend;\n```\nThe first message window displays the following:\nThe original string:\n>Adjusting prices - Please wait.\\<\nThe second message window displays the following:\nThe modified string:\n>Adjusting - Please wait.\\<\n## Related information\ntext-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}