Processing, trim()
用法介紹。
用法
trim(str)
trim(array)
參數
str
(String)
任何字符串array
(String[])
一個字符串數組
返回
String or String[]
說明
從字符串的開頭和結尾刪除空白字符。除了空格、回車和製表符等標準空白字符外,此函數還刪除了 Unicode "nbsp" (U+00A0) 字符和零寬度 no-break 空格 (U+FEFF) 字符。
例子
Table table;
void setup() {
table = new Table();
table.addColumn("name");
table.addColumn("type");
TableRow newRow = table.addRow();
newRow.setString("name", " Lion");
newRow.setString("type", "Mammal");
newRow = table.addRow();
newRow.setString("name", "Snake ");
newRow.setString("type", "Reptile");
newRow = table.addRow();
newRow.setString("name", " Mosquito ");
newRow.setString("type", "Insect");
println(table.getStringColumn("name"));
table.trim();
println(table.getStringColumn("name"));
}
// Sketch prints:
// [0] " Lion"
// [1] "Snake "
// [2] " Mosquito "
// [0] "Lion"
// [1] "Snake"
// [2] "Mosquito"
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);
printArray(a2);
// Prints the following array contents to the console:
// [0] "inconsistent"
// [1] "spacing"
相關用法
- Processing triangle()用法及代碼示例
- Processing true用法及代碼示例
- Processing try用法及代碼示例
- Processing translate()用法及代碼示例
- Processing texture()用法及代碼示例
- Processing thread()用法及代碼示例
- Processing textSize()用法及代碼示例
- Processing textureMode()用法及代碼示例
- Processing textLeading()用法及代碼示例
- Processing text()用法及代碼示例
- Processing textDescent()用法及代碼示例
- Processing this用法及代碼示例
- Processing textFont()用法及代碼示例
- Processing textAscent()用法及代碼示例
- Processing textAlign()用法及代碼示例
- Processing textMode()用法及代碼示例
- Processing textWidth()用法及代碼示例
- Processing tint()用法及代碼示例
- Processing tan()用法及代碼示例
- Processing textureWrap()用法及代碼示例
- Processing FFT用法及代碼示例
- Processing SawOsc.pan()用法及代碼示例
- Processing FloatDict用法及代碼示例
- Processing FFT.stop()用法及代碼示例
- Processing join()用法及代碼示例
注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 trim()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。