Search code examples
htmliosxcodensstringgoogle-finance-api

Extracting a value from a HTML file as an NSString


I'm creating a currency converter and using the Google Finance API to do so.

I'm following these simple instructions.

The URL outputs a page that looks something like this:

{lhs: "100 Euros",rhs: "132.240437 Australian dollars",error: "",icc: true}

My question is, what is the best way to extract the outputted value (132.240437) as a string?


Solution

  • The simplest way is to use RegEx (e.g. RegexKit Lite). For this task you'll need:

    [respStr stringByMatching:@".*rhs: \"([0-9\-\.]*)" capture:1L];