0

Using Jsoup is it possible to remove text characters after whitespace?

For example:

 <td>  4.9 ft</td>

Is it possible to remove the "ft" from the result?

Thank you.

J4C3N-14
  • 666
  • 1
  • 12
  • 30

2 Answers2

2

Jsoup will not help you with that. However, you can parse the Element(s) into a String, and then replace part of the string with another. An example is below:

String parsedstring = YourElement.text();
String replacedstring = parsedstring.replace(" ft",""); 

Here's another question that may help you: Android - how to replace part of a string by another string?

Community
  • 1
  • 1
hichris123
  • 9,955
  • 15
  • 53
  • 68
0

Try this:

1) Save the text as String. 2) Get the length of the String, then use the substring method to remove the last two characters.

Here's an example

String result = Element.text();
int resultLength = result.length();
result = result.substring(0, resultLength -2);

Please note: This is a beginner's advice.

hichris123
  • 9,955
  • 15
  • 53
  • 68
theanimashaun
  • 196
  • 1
  • 1
  • 11
  • Hi, Thanks for sharing your help. I have accepted a different answer but still, thanks for your in-put. Appreciated. – J4C3N-14 Nov 06 '13 at 23:44