"함수 rtrim()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 하나는 보이지 않습니다)
4번째 줄: 4번째 줄:
;rtrim  
;rtrim  
;TrimEnd
;TrimEnd
<source lang='c'>
<syntaxhighlight lang='c'>
output = rtrim(input)
output = rtrim(input)
</source>
</syntaxhighlight>


*input
*input
<source lang='text'>
<syntaxhighlight lang='text'>
"\t  hello  \n"
"\t  hello  \n"
</source>
</syntaxhighlight>
*output
*output
<source lang='text'>
<syntaxhighlight lang='text'>
"\t  hello"
"\t  hello"
</source>
</syntaxhighlight>


==C#==
==C#==
[[category: Csharp]]
[[category: Csharp]]
<source lang='csharp'>
<syntaxhighlight lang='csharp'>
string input = "\t  hello  \n";
string input = "\t  hello  \n";
string output = input.TrimEnd();
string output = input.TrimEnd();
// returns "\t  hello"
// returns "\t  hello"
</source>
</syntaxhighlight>


==Cmd==
==Cmd==
[[category: Cmd]]
[[category: Cmd]]
<source lang='dos'>
<syntaxhighlight lang='dos'>
set my_name=      John Smith        &rem
set my_name=      John Smith        &rem
set trimmed=%my_name%
set trimmed=%my_name%
40번째 줄: 40번째 줄:
REM [      John Smith        ]
REM [      John Smith        ]
REM [      John Smith]
REM [      John Smith]
</source>
</syntaxhighlight>


==JavaScript==
==JavaScript==
[[category: JavaScript]]
[[category: JavaScript]]
<source lang='javascript'>
<syntaxhighlight lang='javascript'>
String.prototype.rtrim = function() {
String.prototype.rtrim = function() {
   return this.replace(/\s+$/,'');
   return this.replace(/\s+$/,'');
51번째 줄: 51번째 줄:
var input = "\t  hello  \n";
var input = "\t  hello  \n";
var output = input.rtrim();
var output = input.rtrim();
</source>
</syntaxhighlight>
<source lang='javascript'>
<syntaxhighlight lang='javascript'>
function rtrim() {
function rtrim() {
   return this.replace(/\s+$/,'');
   return this.replace(/\s+$/,'');
59번째 줄: 59번째 줄:
var input = "\t  hello  \n";
var input = "\t  hello  \n";
var output = rtrim(input);
var output = rtrim(input);
</source>
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='php'>
<syntaxhighlight lang='php'>
$input = "\t  hello  \n";  
$input = "\t  hello  \n";  
$output = rtrim($input );
$output = rtrim($input );
</source>
</syntaxhighlight>
<source lang='php'>
<syntaxhighlight lang='php'>
$input = "\t  hello  \n";  
$input = "\t  hello  \n";  
$output = chop($input ); // alias
$output = chop($input ); // alias
</source>
</syntaxhighlight>


==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang='python'>
<syntaxhighlight lang='python'>
trimmed = "\t  hello  \n".rstrip() # returns "hello"
trimmed = "\t  hello  \n".rstrip() # returns "hello"
</source>
</syntaxhighlight>


==Ruby==
==Ruby==
[[category: Ruby]]
[[category: Ruby]]
<source lang='ruby'>
<syntaxhighlight lang='ruby'>
trimmed = "\t  hello  \n".rstrip # returns "hello"
trimmed = "\t  hello  \n".rstrip # returns "hello"
</source>
</syntaxhighlight>


==SQL==
==SQL==
88번째 줄: 88번째 줄:
===MySQL===
===MySQL===
[[category: MySQL]]
[[category: MySQL]]
<source lang='mysql'>
<syntaxhighlight lang='mysql'>
SELECT RTRIM( "  hello world  " );
SELECT RTRIM( "  hello world  " );
# "  hello world"
# "  hello world"
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 02:33 기준 최신판

1 개요[ | ]

right trim
rtrim
TrimEnd
output = rtrim(input)
  • input
"\t  hello  \n"
  • output
"\t  hello"

2 C#[ | ]

string input = "\t  hello  \n";
string output = input.TrimEnd();
// returns "\t  hello"

3 Cmd[ | ]

set my_name=      John Smith        &rem
set trimmed=%my_name%
IF "%trimmed:~-32%"=="                                " set trimmed=%trimmed:~0,-32%
IF "%trimmed:~-16%"=="                " set trimmed=%trimmed:~0,-16%
IF "%trimmed:~-8%"=="        " set trimmed=%trimmed:~0,-8%
IF "%trimmed:~-4%"=="    " set trimmed=%trimmed:~0,-4%
IF "%trimmed:~-2%"=="  " set trimmed=%trimmed:~0,-2%
IF "%trimmed:~-1%"==" " set trimmed=%trimmed:~0,-1%
echo [%my_name%]
echo [%trimmed%]
REM [      John Smith        ]
REM [      John Smith]

4 JavaScript[ | ]

String.prototype.rtrim = function() {
  return this.replace(/\s+$/,'');
}

var input = "\t  hello  \n";
var output = input.rtrim();
function rtrim() {
  return this.replace(/\s+$/,'');
}

var input = "\t  hello  \n";
var output = rtrim(input);

5 PHP[ | ]

$input = "\t  hello  \n"; 
$output = rtrim($input );
$input = "\t  hello  \n"; 
$output = chop($input ); // alias

6 Python[ | ]

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

7 Ruby[ | ]

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

8 SQL[ | ]

8.1 MySQL[ | ]

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

9 같이 보기[ | ]

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