首页 > 文档 > trim()去空格
2017
07-21

trim()去空格

Name

trim()去空格

   

Examples

String s1 = ” Somerville MA “;

println(s1); // Prints ” Somerville MA ”

String s2 = trim(s1);

println(s2); // Prints “Somerville MA”

 

String[] a1 = { ” inconsistent “, ” spacing” }; // Note spaces

String[] a2 = trim(a1);

println(a2);

// Prints the following array contents to the console:

// [0] “inconsistent”

// [1] “spacing”

Description

Removes whitespace characters from the beginning and end of a String. In addition to standard whitespace characters such as space, carriage return, and tab, this function also removes the Unicode “nbsp” character.

Syntax

trim(str)

trim(array)

Parameters

str

String: any string字符串

array

String[]: a String array字符串数组

Returns

String or String[]

Related

split()
join()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。