# (trim string \[flag\])
[GstarCAD 2011](../../../Index.md) → [Developer Reference](../../%28Developer%20Reference%29.md) → [AutoLISP Reference](../%28AutoLISP%20Reference%29.md) → [LISP Functions](%28LISP%20Functions%29.md)
<a id="299"></a>
## (trim string \[flag\])
---
Erase blank spaces in a string.
---
This function trims spaces from the specified *string*.
The optional *flag* argument represents the options for stripping spaces:
| Flag | Meaning |
| --- | --- |
| none | Strip all spaces from beginning and end. |
| "B" | Strip spaces from beginning of string. |
| "M" | Strip spaces from middle of string. |
| "E" | Strip spaces from end of string. |
| "BE" | Strip spaces from beginning and end of string. |
| "ME" | Strip spaces from middle and end of string. |
| "BM" | Strip spaces from beginning and middle of string. |
### Examples
| Code | Returns |
| --- | --- |
| (setq a " Green Beans " ) | |
| | |
| (**trim** a "B" ) | "Green Beans " |
| (**trim** a "M" ) | " GreenBeans " |
| (**trim** a "be") | "Green Beans" |
| (**trim** a) | "Green Beans" |
**Tell me about...**
[(lpad string integer)](%28lpad%20string%20integer%29.md)
[(rpad string integer)](%28rpad%20string%20integer%29.md)
[(setq symbol1 statement1 \[symbol2 statement2\] ...)](%28setq%20symbol1%20statement1%20-symbol2%20statement2-%20...%29.md)
[LISP Compatibility](../LISP%20Compatibility.md)
[Programming Overview of LISP (LISt Processing) Language](../Programming%20Overview%20of%20LISP%20%28LISt%20Processing%29%20Language.md)
<a id="holding"></a>
## Other versions with matching text
[GstarCAD 2012](../../../../2012/Developer%20Reference/AutoLISP%20Reference/LISP%20Functions/%28trim%20string%20-flag-%29.md)