{"title":"Text.DelChr(Text [, Text] [, Text]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/text/text-delchr-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-delchr-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-delchr-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 chars contained in the which parameter in a string based on the contents on the where parameter.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":798,"chars":168},{"level":2,"title":"Parameters","slug":"parameters","at":966,"chars":228},{"level":2,"title":"Return Value","slug":"return-value","at":1194,"chars":70},{"level":2,"title":"Remarks","slug":"remarks","at":1264,"chars":1424},{"level":2,"title":"Example 1","slug":"example-1","at":2688,"chars":560},{"level":2,"title":"Example 2","slug":"example-2","at":3248,"chars":511},{"level":2,"title":"Example 3","slug":"example-3","at":3759,"chars":543},{"level":2,"title":"Example 4","slug":"example-4","at":4302,"chars":546},{"level":2,"title":"Example 5","slug":"example-5","at":4848,"chars":499},{"level":2,"title":"Example 6","slug":"example-6","at":5347,"chars":439},{"level":2,"title":"Related information","slug":"related-information","at":5786,"chars":132}],"text":"> Version: _Available or changed with runtime version 1.0._\nDeletes chars contained in the which parameter in a string based on the contents on the where parameter. If the where parameter contains an equal-sign, then all occurrences of characters in which is deleted from the current value. If the where parameter contains a less-than, then the characters are only deleted when they are first in the string. If the where parameter contains a greater-than, then the characters are only deleted when they are the last in the string. If the where parameter contains any other char, an exception is thrown. If the where parameter or the which parameter is empty, the source is returned unmodified. The which parameter is to be considered as an array of chars to delete where the order does not matter.\n## Syntax\n```al\nNewString :=   Text.DelChr(String: Text [, Where: Text] [, Which: Text])\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.\n*[Optional] Where*\nType: text-data-type\nSpecifies where to delete characters.\n*[Optional] Which*\nType: text-data-type\nSpecifies the characters that you want to delete.\n## Return Value\nNewString\nType: text-data-type\nThe end result String.\n## Remarks\nThe DelChr method is case-sensitive.\nIf you omit the Which parameter, then the method deletes spaces from String based on the contents of the Where parameter as follows:\n If Where contains =, then all the spaces are deleted from String.\n If Where contains \\<, then all the spaces at the start of String are deleted.\n If Where contains >, then all the spaces at the end of String are deleted.\n If Where contains any other character, then an error is returned.\n If Where is empty, then String is returned unchanged.\nIf you use the Where and the Which parameters, then the method deletes from String the characters that are contained in the Which parameter based on the contents of the Where parameter as follows:\n If Where contains =, then every occurrence of the characters in Which are deleted from String.\n If Where contains \\<, then the characters in Which are only deleted if they occur at the start of String.\n If Where contains >, then the characters in Which are deleted only if they occur at the end of String.\n If Where contains any other character, then an error is returned.\n If Where is empty, then String is returned unchanged.\n If Which is empty, then String is returned unchanged.\nThe Which parameter contains an array of the characters that you want to delete. The order of the characters is of no significance. If String contains a character that is specified in Which, it is deleted from String.\n## Example 1\n```al\nvar\n    String: Text;\n    Where: Text;\n    Which: Text;\n    NewString: Text;\n    Text000: TexConst ENU='Windy West Solutions';\n    Text001: TexConst ENU='>%1< is transformed to >%2<';\nbegin\n    String := Text000;\n    Where := '<>';\n    Which := 'Ws';\n    NewString := DelChr(String, Where, Which);\n    Message(Text001, String,NewString);\nend;\n```\nThe message window displays the following:\n>Windy West Solutions\\< is transformed to >indy West Solution\\<\nThe method deletes every W and s that is either the first or last character in String.\n## Example 2\n```al\nvar\n    String: Text;\n    Where: Text;\n    Which: Text;\n    NewString: Text;\n    Text000: TexConst ENU='This is an example';\n    Text001: TexConst ENU='>%1< is transformed to >%2<';\nbegin\n    String := Text000;\n    Where := '=';\n    Which := 'sx';\n    NewString := DelChr(String, Where, Which);\n    Message(Text001, String,NewString);\nend;\n```\nThe message window displays the following:\n>This is an example\\< is transformed to >Thi i an eample\\<\nThe method deletes every s and x from String.\n## Example 3\n```al\nvar\n    String: Text;\n    Where: Text;\n    Which: Text;\n    NewString: Text;\n    Text000: TexConst ENU='This is an example';\n    Text001: TexConst ENU='>%1< is transformed to >%2<';\nbegin\n    String := Text000;\n    Where := '>';\n    Which := 'Tely';\n    NewString := DelChr(String, Where, Which);\n    Message(Text001, String,NewString);\nend;\n```\nThe message window displays the following:\n>This is an example\\< is transformed to >This is an examp\\<\nIf T, e, l, or y is the last character in String, the method deletes them.\n## Example 4\n```al\nvar\n    String: Text;\n    Where: Text;\n    Which: Text;\n    NewString: Text;\n    Text000: TexConst ENU='This is an example';\n    Text001: TexConst ENU='>%1< is transformed to >%2<';\nbegin\n    String := Text000;\n    Where := '<';\n    Which := 'This ';\n    NewString := DelChr(String, Where, Which);\n    Message(Text001, String,NewString);\nend;\n```\nThe message window displays the following:\n>This is an example\\< is transformed to >an example\\<\nIf T, h, s, i, or space is the first character in String, the method deletes them.\n## Example 5\n```al\nvar\n    String: Text;\n    Where: Text;\n    Which: Text;\n    NewString: Text;\n    Text000: TexConst ENU='This is an example';\n    Text001: TexConst ENU='>%1< is transformed to >%2<';\nbegin\n    String := Text000;\n    Where := '<';\n    NewString := DelChr(String, Where);\n    Message(Text001, String,NewString);\nend;\n```\nThe message window displays the following:\n> This is an example\\< is transformed to >This is an example\\<\nThe method removes any spaces from the start of String.\n## Example 6\n```al\nvar\n    String: Text;\n    NewString: Text;\n    Text000: Label ' Windy West Solutions '; // note that there can be multiple leading and trailing spaces\n    Text001: Label '>%1< is transformed to >%2<';\nbegin\n    String := Text000;\n    NewString := DelChr(String);\n    Message(Text001, String, NewString);\nend;\n```\nThe message window displays the following:\n> Windy West Solutions < is transformed to >WindyWestSolutions<\n## Related information\ntext-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}