---
id: post/yzhums-com/65578
type: post
title: "Dynamics 365 Business Central: How to quickly remove white-space characters from the current Text/String (leading, trailing and all) in AL"
summary: "This post explains four methods to remove whitespace characters from text strings in AL: TrimStart for leading spaces, TrimEnd for trailing spaces, Trim for both leading and trailing, and DelChr for all whitespace. It includes working code examples showing each method in a test page."
tier: community
language: en
tags:
  - al development
  - text manipulation
  - string functions
  - whitespace handling
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-26T06:42:45.010Z"
  flags: []
generated:
  at: "2026-10-26T05:51:10.938Z"
  pipeline: 0.2.0
  prompts:
    extract-post: 1
  input_hash: 55a9915218e3dc9b742038ea9b74f7debaabab54e1cbd685cbeb74e6e096ffff
evidence:
  - kind: blog
    url: https://yzhums.com/65578/
    title: "Dynamics 365 Business Central: How to quickly remove white-space characters from the current Text/String (leading, trailing and all) in AL"
    date: "2025-07-04"
    commit: null
    t: null
    quote: null
  - kind: blog
    url: https://yzhums.com/65578/
    title: "Dynamics 365 Business Central: How to quickly remove white-space characters from the current Text/String (leading, trailing and all) in AL"
    date: "2025-07-04"
    commit: null
    t: null
    quote: Removes all leading occurrences of a set of characters specified in an array from the current Text object.
  - kind: blog
    url: https://yzhums.com/65578/
    title: "Dynamics 365 Business Central: How to quickly remove white-space characters from the current Text/String (leading, trailing and all) in AL"
    date: "2025-07-04"
    commit: null
    t: null
    quote: Returns a new Text in which all leading and trailing white-space characters from the current Text object are removed.
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
post_id: "65578"
source_id: yzhums-com
source_name: Dynamics 365 Lab - Yun Zhu
url: https://yzhums.com/65578/
published_at: "2025-07-04T01:34:15.000Z"
author: Yun Zhu
full_text: false
words: 515
quotes:
  - text: Removes all leading occurrences of a set of characters specified in an array from the current Text object.
    why_it_matters: Explains what TrimStart does, essential for understanding when to use this method
  - text: Returns a new Text in which all leading and trailing white-space characters from the current Text object are removed.
    why_it_matters: Describes Trim's dual functionality, useful for the most common whitespace removal scenario
code_objects_mentioned:
  - page Remove Spaces
systems:
  - development
  - platform
versions_mentioned:
  - 2023 wave 1
preview:
  embeddable: true
  frame_url: null
  image: https://yzhums.com/wp-content/uploads/2025/07/Snipaste_2025-07-03_16-54-50.png
  image_alt: null
  image_w: null
  image_h: null
  site_name: Dynamics 365 Lab
  favicon: https://yzhums.com/wp-content/uploads/2020/08/cropped-logo-3-32x32.png
  probed_at: "2026-10-26T06:18:18.978Z"
---

# Dynamics 365 Business Central: How to quickly remove white-space characters from the current Text/String (leading, trailing and all) in AL

[Read the post](https://yzhums.com/65578/) · Dynamics 365 Lab - Yun Zhu (Yun Zhu, MVP) · 2025-07-04 · 515 words · tier community · reviewed (checked by Opus)

> This post explains four methods to remove whitespace characters from text strings in AL: TrimStart for leading spaces, TrimEnd for trailing spaces, Trim for both leading and trailing, and DelChr for all whitespace. It includes working code examples showing each method in a test page.

## Key points

- TrimStart() removes only leading whitespace characters
- TrimEnd() removes only trailing whitespace characters
- Trim() removes both leading and trailing whitespace in one call
- DelChr() can remove all whitespace characters from anywhere in the string
- Each method has specific use cases depending on which whitespace needs to be removed

## Quotes

- "Removes all leading occurrences of a set of characters specified in an array from the current Text object." (Explains what TrimStart does, essential for understanding when to use this method)
- "Returns a new Text in which all leading and trailing white-space characters from the current Text object are removed." (Describes Trim's dual functionality, useful for the most common whitespace removal scenario)

## AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

- page "Remove Spaces"

Not found in BC28-30: page "Remove Spaces".

## Context

- Features: TrimStart method, TrimEnd method, Trim method, DelChr method, text manipulation
- Versions: 2023 wave 1

Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.
