<div> id: 123456 has been successfully submitted. <br/> <br/> </div>
In the above code, I am able to retrieve the whole text. But I need to retrieve the id value which is 123456 here and store it in an excel sheet. Help me in retrieving the numeric value?
Thanks in Advance
To extract the numeric value from your string:
int i = Integer.parseInt(html.replaceAll("\\D", ""));
The regex \\D
means "any non-digit", and replaceAll()
is deleting all non-digits by replacing them with nothing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.