Strings.Trim(String) 메서드
정의
선행 공백(LTrim
), 후행 공백(RTrim
), 선행 또는 후행 공백(Trim
)이 없는 지정된 문자열의 복사본이 포함된 문자열을 반환합니다.Returns a string containing a copy of a specified string with no leading spaces (LTrim
), no trailing spaces (RTrim
), or no leading or trailing spaces (Trim
).
public:
static System::String ^ Trim(System::String ^ str);
public static string Trim (string? str);
public static string Trim (string str);
static member Trim : string -> string
Public Function Trim (str As String) As String
매개 변수
- str
- String
필수 요소.Required. 임의의 유효한 String
식입니다.Any valid String
expression.
반환
선행 공백(LTrim
), 후행 공백(RTrim
), 선행 또는 후행 공백(Trim
)이 없는 지정된 문자열의 복사본이 포함된 문자열입니다.A string containing a copy of a specified string with no leading spaces (LTrim
), no trailing spaces (RTrim
), or no leading or trailing spaces (Trim
).
예제
이 예제에서는 문자열 변수에서 LTrim
함수를 사용하여 선행 공백을 제거하고 RTrim
함수를 사용하여 후행 공백을 제거하며This example uses the LTrim
function to strip leading spaces and the RTrim
function to strip trailing spaces from a string variable. Trim
함수를 사용하여 양쪽 공백을 모두 제거합니다.It uses the Trim
function to strip both types of spaces.
' Initializes string.
Dim testString As String = " <-Trim-> "
Dim trimString As String
' Returns "<-Trim-> ".
trimString = LTrim(testString)
' Returns " <-Trim->".
trimString = RTrim(testString)
' Returns "<-Trim->".
trimString = LTrim(RTrim(testString))
' Using the Trim function alone achieves the same result.
' Returns "<-Trim->".
trimString = Trim(testString)
설명
LTrim
, RTrim
및 함수는 Trim
문자열의 끝에서 공백을 제거 합니다.The LTrim
, RTrim
, and Trim
functions remove spaces from the ends of strings.