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

1번째 줄: 1번째 줄:
[[category: String]]
==개요==
;right trim
;right trim
;rtrim  
;rtrim  
;TrimEnd
;TrimEnd
==Overview==
<source lang='c'>
<source lang='c'>
output = rtrim(input)
output = rtrim(input)
18번째 줄: 18번째 줄:


==C#==
==C#==
[[category: Csharp]]
<source lang='csharp'>
<source lang='csharp'>
string input = "\t  hello  \n";
string input = "\t  hello  \n";
25번째 줄: 26번째 줄:


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


==Javascript==
==JavaScript==
[[category: JavaScript]]
<source lang='javascript'>
<source lang='javascript'>
String.prototype.rtrim = function() {
String.prototype.rtrim = function() {
59번째 줄: 62번째 줄:


==PHP==
==PHP==
[[category: PHP]]
<source lang='php'>
<source lang='php'>
$input = "\t  hello  \n";  
$input = "\t  hello  \n";  
69번째 줄: 73번째 줄:


==Python==
==Python==
[[category: Python]]
<source lang='python'>
<source lang='python'>
trimmed = "\t  hello  \n".rstrip() # returns "hello"
trimmed = "\t  hello  \n".rstrip() # returns "hello"
74번째 줄: 79번째 줄:


==Ruby==
==Ruby==
[[category: Ruby]]
<source lang='ruby'>
<source lang='ruby'>
trimmed = "\t  hello  \n".rstrip # returns "hello"
trimmed = "\t  hello  \n".rstrip # returns "hello"
79번째 줄: 85번째 줄:


==SQL==
==SQL==
[[category: SQL]]
===MySQL===
===MySQL===
[[category: MySQL]]
<source lang='mysql'>
<source lang='mysql'>
SELECT RTRIM( "  hello world  " );
SELECT RTRIM( "  hello world  " );
88번째 줄: 96번째 줄:
*[[trim]]
*[[trim]]
*[[ltrim]]
*[[ltrim]]
[[category: String]]
[[category: Csharp]]
[[category: Cmd]]
[[category: Javascript]]
[[category: PHP]]
[[category: SQL]]
[[category: MySQL]]

2015년 2월 19일 (목) 12:17 판

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 shows [      John Smith        ]
REM shows [      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 }}