- left trim
- ltrim
- trim left
- TrimStart
1 C#[ | ]
C#
Copy
string str = "\t hello \n";
string trimmed = str.TrimStart();
// returns "hello \n"
2 Cmd[ | ]
bat
Copy
set str= hello world &rem
for /f "tokens=* delims= " %a in ("%str%") do set trimmed=%a
echo [%str%]
echo [%trimmed%]
REM shows [ hello world ]
REM shows [hello world ]
bat
Copy
set my_name= John Smith &rem
set trimmed=%my_name%
IF "%trimmed:~0,32%"==" " set trimmed=%trimmed:~32%
IF "%trimmed:~0,16%"==" " set trimmed=%trimmed:~16%
IF "%trimmed:~0,8%"==" " set trimmed=%trimmed:~8%
IF "%trimmed:~0,4%"==" " set trimmed=%trimmed:~4%
IF "%trimmed:~0,2%"==" " set trimmed=%trimmed:~2%
IF "%trimmed:~0,1%"==" " set trimmed=%trimmed:~1%
echo [%my_name%]
echo [%trimmed%]
REM shows [ John Smith ]
REM shows [John Smith ]
3 JavaScript[ | ]

JavaScript
Copy
var str = " HELLO ".replace(/^\s+/,'');
console.log("["+str+"]");
// [HELLO ]
JavaScript
Copy
String.prototype.ltrim=function(){return this.replace(/^\s+/,'');}
var str = " HELLO ";
var trimmed = str.ltrim();
4 PHP[ | ]
PHP
Copy
$trimmed = ltrim("\t hello \n"); // returns "hello \n"
5 Python[ | ]
Python
Copy
trimmed = "\t hello \n".lstrip() # returns "hello"
6 Ruby[ | ]
Ruby
Copy
trimmed = "\t hello \n".lstrip # returns "hello"
7 SQL[ | ]
7.1 MySQL[ | ]
MySQL
Copy
SELECT LTRIM( " hello world " );
# "hello world "