함수 ltrim()

left trim
ltrim
trim left
TrimStart

1 C#[ | ]

string str = "\t  hello  \n";
string trimmed = str.TrimStart();
// returns "hello  \n"

2 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        ]

3 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();

4 PHP[ | ]

$trimmed = ltrim("\t  hello  \n"); // returns "hello  \n"

5 Python[ | ]

trimmed = "\t  hello  \n".lstrip() # returns "hello"

6 Ruby[ | ]

trimmed = "\t  hello  \n".lstrip # returns "hello"

7 SQL[ | ]

7.1 MySQL[ | ]

SELECT LTRIM( "  hello world  " );
# "hello world  "

8 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}