Parsing HTTP get response to extract values
First of all, I would avoid using the String class, because of the
memory fragmentation issues that come with it. The most obvious solution
is probably to store the result in a character array, then parse the
array, with strstr() or sscanf(), to extract the values you want.
However, this requires storing the whole response in RAM, which is
expensive. A better option is to parse the string as it comes, character
by character, using a kind of finite state machine.

Here is how I would do it. First, I assume you know what you want to do
with these values. Since I don't, I will instead use this dummy function
to just print the values out to the serial port:



static void parse_relay_callback(uint8_t index, uint8_t value)
{
    Serial.print("parsed: relay ");
    Serial.print(index);
    Serial.print(": ");
    Serial.println(value);
}


You will have to replace this with whatever is appropriate for your
application.

Then here is the parser:

static void parse_relay(char c)
{
    static const char templ[] = "RelayI = V#"; // I: index, V: value
    static uint8_t pos, index, value;
    char expected = templ[pos++];
    if (expected == 'I' &amp;&amp; c &gt;= '0' &amp;&amp; c &lt;= '4')
        index = c - '0';
    else if (expected == 'V' &amp;&amp; (c == '0' || c == '1'))
        value = c - '0';
    else if (expected == '#' &amp;&amp; c == '#')
        parse_relay_callback(index, value);
    else if (c != expected)
        pos = 0;
}


You just feed it one character at a time, with something like:

while (ESP8266.available())
    parse_relay(ESP8266.read());


Feeding the parser with your response example gives the following on the
serial port:

parsed: relay 1: 1
parsed: relay 2: 0
parsed: relay 3: 0
parsed: relay 4: 1