說明
Use this function to remove leading, trailing, and excess spaces from text. Supported in Chains.
TRIM is useful for cleaning up text data by removing unnecessary spaces.
語法
TRIM(text)
Inputs
This function accepts the following argument:
名稱 | 必要 | 說明 | Valid input |
---|---|---|---|
文字|收發簡訊 |
是 | The text from which you want to remove spaces. | Any text string or cell reference containing text. |
範例
資料
A | B |
---|---|
Hello World ! | 45 |
This is a spacey sentence. | This is a spacey sentence. |
First | 名稱 |
Middle | Branch |
67 | Last |
結果
公式 | 說明 | 結果 |
---|---|---|
=TRIM(A1) |
Applies the TRIM function to cell A1 | Hello World ! |
=TRIM(A2) |
Applies the TRIM function to cell A2 | This is a space-y sentence. |
=TRIM(CONCATENATE(A3, A4, B5)) |
Applies the TRIM function to the CONCATENATE formula. This could also be written as: =CONCATENATE(TRIM(A3), " ", TRIM(A4), " ", TRIM(B5)) |
First, Middle, Last |
附註
- TRIM removes all spaces from the beginning and end of a text string.
- It also reduces multiple spaces between words to a single space.
- TRIM doesn't affect spaces represented by non-breaking space characters.
提示
- Use TRIM to clean up data imported from other sources that may contain inconsistent spacing.
- Combine TRIM with other text functions such as CONCATENATE for more complex text manipulation.
- TRIM is particularly useful when preparing data for analysis or presentation. It's also useful for diagnosing failed formulas (by removing extra blank characters).
Related functions
CHAR
CODE
CONCATENATE
CONCATENATEIF
FIND
LEFT
LEN
LOWER
MID
PROPER
REPT
RIGHT
SEARCH
SUBSTITUTE
TEXT
TEXTJOIN
TRIM
UNICHAR
UNICODE
UPPER