Question

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.

Was it helpful?

Solution

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?

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top