I am sending strings to an Esp8266 via web browser.

The below code returns the following in serial monitor if I send in browser:

Send from browser to esp8266 -
Receive in Arduino Serial monitor - GET /s1s2s3s4s5d2 HTTP/1.1

How do i read only the contents s1s2s3s4s5d1 ? This content can vary in length, numbers could be double digits but alphabets will remain in between.

Please note I am still a novice.

// Read the first line of the request
String request = client.readStringUntil('\r');
  • google arduino parsing strings
    – jsotola
    Commented Jan 2, 2019 at 17:55
  • Thanks, i have tried to implement some methods unsuccessfully. i simply do not have the experience especially since the content required varies in length. i was hoping to get an example if possible.
    – S B
    Commented Jan 2, 2019 at 18:00
  • do you have any control over the URL format ....maybe you need to use something like
    – jsotola
    Commented Jan 2, 2019 at 18:11
  • will this method retain the letters or does it strip to numbers?
    – S B
    Commented Jan 2, 2019 at 18:55

2 Answers 2


I have this

if (client.connected()) {
  if (client.available() && client.find(' ')) { // GET /fn HTTP/1.1
    char fn[20];
    int l = client.readBytesUntil(' ', fn, sizeof(fn));
    fn[l] = 0;
    while (client.read() != -1);
  • Thank you, will apply solution and revert.
    – S B
    Commented Jan 2, 2019 at 18:54
  • @s-b, did it help?
    – Juraj
    Commented Jan 29, 2019 at 19:51

you can try something like this

int first_space = request.indexOf(' '); // location of the first space
int second_space = request.indexOf(' ', first_space); // the next space after first

String query_arg = request.substring(first_space,second_space);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.