Arduino Ethernet reading webserver input

Hey all i am wondering how i can get only my needed information from my URL using this ethernet Arduino code:

             if(!sentHeader){
                  // send a standard http response header
                  client.println("HTTP/1.1 200 OK");
                  client.println("Content-Type: text/html");
                  client.println();
                  client.println("<!DOCTYPE HTML>");
                  client.println("<html>");
                  sentHeader = true;
              }
    
              char c = client.read();
              
              //read char by char HTTP request
              if (readString.length() < 100) {
                readString += c;
              } 

              if(reading && c == ' ') reading = false;
              if(c == '?') reading = true; //found the ?, begin reading the info
      
              if(reading){
                  Serial.print(c);
              etc etc etc...

              if (c == '\n' && currentLineIsBlank)  break;
      
              if (c == '\n') {
                  currentLineIsBlank = true;
              }else if (c != '\r') {
                  currentLineIsBlank = false;
              }
          }
      }
      
      client.println("<p>server Arduino
");
      client.println("=======================
");
      client.println("Called: <strong>");
      client.print(readString);
      client.print("</strong></p>");
      client.println("</html>");
      delay(1); // give the web browser time to receive the data
      client.stop(); // close the connection:

If i do:

       http://192.168.9.52:199/?yu7f

I get

server Arduino
=======================
Called: 100GET /?yu7f HTTP/1.1 Host: 192.168.9.199:199 Connection: keep-alive Cache-Control: max-age=0 A
return on the page…

What do i need to add in order to get all the characters after the “?”. That being only yu7f

Using the String functions you could find the location of the ? in the string and then capture the following three characters.

I've tried:

readString = readString.substring(15, 5);

but that only comes up with:

100GET /?yu7f

for some reason? Not sure why its not starting at the 15th char and only going 5 out from there?

This is my current code:

if (client) {  
      // an http request ends with a blank line
      boolean currentLineIsBlank = true;
      boolean sentHeader = false;
      String readString = String(100); //string for fetching data from address
  
      while (client.connected()) {
          if (client.available()) {  
              if(!sentHeader){
                  // send a standard http response header
                  client.println("HTTP/1.1 200 OK");
                  client.println("Content-Type: text/html");
                  client.println();
                  client.println("<!DOCTYPE HTML>");
                  client.println("<html>");
                  sentHeader = true;
              }
    
              char c = client.read();
              
              //read char by char HTTP request
              if (readString.length() < 13) {
                readString += c;
              } 
              
              //readString.replace('100GET','.');
              //int firstClosingBracket = readString.indexOf('?');
              //String readString1 = readString.substring(1, 5);
              
              if(reading && c == ' ') reading = false;
              if(c == '?') reading = true; //found the ?, begin reading the info
      
              if(reading){
                  Serial.print(c); 
                  client.println(readString);
                  
                  if (c == 'r1on') {
                    digitalWrite(relay1, LOW); //Turn 5v USB power ON
                  } else if (c == 'r1off') {
                    digitalWrite(relay1, HIGH); //Turn 5v USB power OFF
                  } else if (c == 'r2') {
                    digitalWrite(relay2, LOW); //Eject bluray Disc
                    delay(500); //pause for 1/2 second
                    digitalWrite(relay2, HIGH);
                  } else if (c == 'r3') {
                    digitalWrite(relay3, LOW); //"Push" the pc power button
                    delay(500); //pause for 1/2 second
                    digitalWrite(relay3, HIGH); //"Release" the pc power button
                  }           
              }
    
              if (c == '\n' && currentLineIsBlank)  break;
      
              if (c == '\n') {
                  currentLineIsBlank = true;
              }else if (c != '\r') {
                  currentLineIsBlank = false;
              }
          }
      }
      
      client.println("<p>server Arduino
");
      client.println("=======================
");
      client.println("Called: <strong>");
      client.print(readString);
      client.print("</strong></p>");
      client.println("</html>");
      delay(1); // give the web browser time to receive the data
      client.stop(); // close the connection:  
    }

And the output is:

100GET /? 100GET /?1 100GET /?12 100GET /?123 100GET /?1234
server Arduino

Called: 100GET /?1234

It doesn’t seem to be reading the whole string BEFORE it trys to substring?

You need to post ALL of your code, not just the snippets you think might be related to the problem.

I'd also suggest that you learn to prefix what you print to the serial monitor with useful information, so you can tell exactly which Serial.print() statement printed what character(s).

StealthRT:
I've tried:

readString = readString.substring(15, 5);

but that only comes up with:

100GET /?yu7f

for some reason? Not sure why its not starting at the 15th char and only going 5 out from there?

Well, do a little experimenting. You are probably not counting spaces and such in the original string. Try the below and see if it is closer.

readString = readString.substring(25, 5);