[英]Java String trim has no effect
Java String trim is not removing a whitespace character for me. Java String trim不为我删除空格字符。
String rank = (some method);
System.out.println("(" + rank + ")");
The output is (1 )
.输出为
(1 )
。 Notice the space to the right of the 1.请注意1右边的空间。
I have to remove the trailing space from the string rank
but neither rank.trim()
nor rank.replace(" ","")
removes it.我必须从字符串
rank
删除尾随空格,但rank.trim()
或rank.replace(" ","")
不会删除它。
The string rank
just remains the same either way.无论哪种方式,字符串
rank
保持不变。
Edit: Full Code: :编辑:完整代码::
Document doc = Jsoup.connect("http://www.4icu.org/ca/").timeout(1000000).get();
Element table = doc.select("table").get(7);
Elements rows = table.select("tr");
for (Element row: rows) {
String rank = row.select("span").first().text().trim();
System.out.println("("+rank+")");
}
Why can't I remove that space?为什么我不能删除那个空间?
Java String trim is not removing a whitespace character for me. Java String trim不为我删除空格字符。
String rank = (some method);
System.out.println("(" + rank + ")");
The output is (1 )
.输出为
(1 )
。 Notice the space to the right of the 1.请注意1右边的空间。
I have to remove the trailing space from the string rank
but neither rank.trim()
nor rank.replace(" ","")
removes it.我必须从字符串
rank
删除尾随空格,但rank.trim()
或rank.replace(" ","")
不会删除它。
The string rank
just remains the same either way.无论哪种方式,字符串
rank
保持不变。
Edit: Full Code: :编辑:完整代码::
Document doc = Jsoup.connect("http://www.4icu.org/ca/").timeout(1000000).get();
Element table = doc.select("table").get(7);
Elements rows = table.select("tr");
for (Element row: rows) {
String rank = row.select("span").first().text().trim();
System.out.println("("+rank+")");
}
Why can't I remove that space?为什么我不能删除那个空间?
Java String trim is not removing a whitespace character for me. Java String trim不为我删除空格字符。
String rank = (some method);
System.out.println("(" + rank + ")");
The output is (1 )
.输出为
(1 )
。 Notice the space to the right of the 1.请注意1右边的空间。
I have to remove the trailing space from the string rank
but neither rank.trim()
nor rank.replace(" ","")
removes it.我必须从字符串
rank
删除尾随空格,但rank.trim()
或rank.replace(" ","")
不会删除它。
The string rank
just remains the same either way.无论哪种方式,字符串
rank
保持不变。
Edit: Full Code: :编辑:完整代码::
Document doc = Jsoup.connect("http://www.4icu.org/ca/").timeout(1000000).get();
Element table = doc.select("table").get(7);
Elements rows = table.select("tr");
for (Element row: rows) {
String rank = row.select("span").first().text().trim();
System.out.println("("+rank+")");
}
Why can't I remove that space?为什么我不能删除那个空间?
Java String trim is not removing a whitespace character for me. Java String trim不为我删除空格字符。
String rank = (some method);
System.out.println("(" + rank + ")");
The output is (1 )
.输出为
(1 )
。 Notice the space to the right of the 1.请注意1右边的空间。
I have to remove the trailing space from the string rank
but neither rank.trim()
nor rank.replace(" ","")
removes it.我必须从字符串
rank
删除尾随空格,但rank.trim()
或rank.replace(" ","")
不会删除它。
The string rank
just remains the same either way.无论哪种方式,字符串
rank
保持不变。
Edit: Full Code: :编辑:完整代码::
Document doc = Jsoup.connect("http://www.4icu.org/ca/").timeout(1000000).get();
Element table = doc.select("table").get(7);
Elements rows = table.select("tr");
for (Element row: rows) {
String rank = row.select("span").first().text().trim();
System.out.println("("+rank+")");
}
Why can't I remove that space?为什么我不能删除那个空间?
Java String trim is not removing a whitespace character for me. Java String trim不为我删除空格字符。
String rank = (some method);
System.out.println("(" + rank + ")");
The output is (1 )
.输出为
(1 )
。 Notice the space to the right of the 1.请注意1右边的空间。
I have to remove the trailing space from the string rank
but neither rank.trim()
nor rank.replace(" ","")
removes it.我必须从字符串
rank
删除尾随空格,但rank.trim()
或rank.replace(" ","")
不会删除它。
The string rank
just remains the same either way.无论哪种方式,字符串
rank
保持不变。
Edit: Full Code: :编辑:完整代码::
Document doc = Jsoup.connect("http://www.4icu.org/ca/").timeout(1000000).get();
Element table = doc.select("table").get(7);
Elements rows = table.select("tr");
for (Element row: rows) {
String rank = row.select("span").first().text().trim();
System.out.println("("+rank+")");
}
Why can't I remove that space?为什么我不能删除那个空间?
Java String trim is not removing a whitespace character for me. Java String trim不为我删除空格字符。
String rank = (some method);
System.out.println("(" + rank + ")");
The output is (1 )
.输出为
(1 )
。 Notice the space to the right of the 1.请注意1右边的空间。
I have to remove the trailing space from the string rank
but neither rank.trim()
nor rank.replace(" ","")
removes it.我必须从字符串
rank
删除尾随空格,但rank.trim()
或rank.replace(" ","")
不会删除它。
The string rank
just remains the same either way.无论哪种方式,字符串
rank
保持不变。
Edit: Full Code: :编辑:完整代码::
Document doc = Jsoup.connect("http://www.4icu.org/ca/").timeout(1000000).get();
Element table = doc.select("table").get(7);
Elements rows = table.select("tr");
for (Element row: rows) {
String rank = row.select("span").first().text().trim();
System.out.println("("+rank+")");
}
Why can't I remove that space?为什么我不能删除那个空间?
Java String trim is not removing a whitespace character for me. Java String trim不为我删除空格字符。
String rank = (some method);
System.out.println("(" + rank + ")");
The output is (1 )
.输出为
(1 )
。 Notice the space to the right of the 1.请注意1右边的空间。
I have to remove the trailing space from the string rank
but neither rank.trim()
nor rank.replace(" ","")
removes it.我必须从字符串
rank
删除尾随空格,但rank.trim()
或rank.replace(" ","")
不会删除它。
The string rank
just remains the same either way.无论哪种方式,字符串
rank
保持不变。
Edit: Full Code: :编辑:完整代码::
Document doc = Jsoup.connect("http://www.4icu.org/ca/").timeout(1000000).get();
Element table = doc.select("table").get(7);
Elements rows = table.select("tr");
for (Element row: rows) {
String rank = row.select("span").first().text().trim();
System.out.println("("+rank+")");
}
Why can't I remove that space?为什么我不能删除那个空间?
Java String trim is not removing a whitespace character for me. Java String trim不为我删除空格字符。
String rank = (some method);
System.out.println("(" + rank + ")");
The output is (1 )
.输出为
(1 )
。 Notice the space to the right of the 1.请注意1右边的空间。
I have to remove the trailing space from the string rank
but neither rank.trim()
nor rank.replace(" ","")
removes it.我必须从字符串
rank
删除尾随空格,但rank.trim()
或rank.replace(" ","")
不会删除它。
The string rank
just remains the same either way.无论哪种方式,字符串
rank
保持不变。
Edit: Full Code: :编辑:完整代码::
Document doc = Jsoup.connect("http://www.4icu.org/ca/").timeout(1000000).get();
Element table = doc.select("table").get(7);
Elements rows = table.select("tr");
for (Element row: rows) {
String rank = row.select("span").first().text().trim();
System.out.println("("+rank+")");
}
Why can't I remove that space?为什么我不能删除那个空间?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.