Trim Spaces from Strings in Classic ASP

LTrim() removes leading spaces, RTrim() removes trailing spaces, and Trim() removes both leading and trailing spaces.

Remove leading spaces

Dim my_string
my_string=" Welcome to Plus2net.com"
Response.Write "Before removing space =|" & my_string & "|"
my_string=LTrim(my_string)
Response.Write "<br>After removing space =|" & my_string & "|"

Output

Before removing space =| Welcome to Plus2net.com|
After removing space =|Welcome to Plus2net.com|

The vertical bars make the leading space visible in the output.

Remove trailing spaces

my_string=RTrim(my_string)

Remove spaces from both ends

my_string=Trim(my_string)
These functions remove space characters at the edges of the string; they do not remove or collapse spaces in the middle. If the argument is Null, the result is Null.

ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer