+ Start a Discussion

Retrieving value of HTML response page in apex class


Can any body tell me the way to retrieve the content displayed in a HTML response.

The response page displays something like this:  STATUS: 920

If I  can get that number(here,920) and if I can store it in a string, my task will be completed.


Please, help me.


hey abhi,



Are you doing a callout to an endpoint and getting "STATUS: 920" as the response? If so you can get the number by doing a regular expression match.

You will need a regular expression that can get you the number, for example :



.*STATUS: ([0-9]*).*

 That will match a string with anything in the start , anything at the end, has the string "STATUS: " inside then followed by a




public String regex = '.*STATUS: ([0-9]*).*';
matcher mt = pt.matcher(test1.Description__c);
String numberFound = mt.group(1); // This will have the number



Let me know if this is what you wanted and if it works out,