- left trim
- ltrim
- trim left
- TrimStart
C#
string str = "\t hello \n";
string trimmed = str.TrimStart();
// returns "hello \n"
Cmd
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 ]
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 ]
JavaScript
var str = " HELLO ".replace(/^\s+/,'');
console.log("["+str+"]");
// [HELLO ]
String.prototype.ltrim=function(){return this.replace(/^\s+/,'');}
var str = " HELLO ";
var trimmed = str.ltrim();
PHP
$trimmed = ltrim("\t hello \n"); // returns "hello \n"
Python
trimmed = "\t hello \n".lstrip() # returns "hello"
Ruby
trimmed = "\t hello \n".lstrip # returns "hello"
SQL
MySQL
SELECT LTRIM( " hello world " );
# "hello world "
같이 보기