1

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
  • 686
  • 1
  • 13
  • 32

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
  • 10,145
  • 15
  • 56
  • 70
  • Lovely, Thanks I modded it slightly...String parsedstring = yourElement.text().replace(" ft", ""); Thank you. – J4C3N-14 Nov 06 '13 at 23:46
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
  • 10,145
  • 15
  • 56
  • 70
theanimashaun
  • 306
  • 1
  • 2
  • 12
  • 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