Problems with substring

Hey guys, i'm trying to figure out how i can receive commands from sms with a sim900 shield. I can send and receive messages no problem, but i'm having trouble figuring out how to extract just the command from the sms. I have the code below that i've put together, but it's not working. Anyone have an idea as to why? It finds the # and sets the index correctly, but it's not matching the string when i send #lock or #unlock thru the serial monitor.

void setup() {
  Serial.begin(19200);
}

void loop() {

String content = "";
  char character;

  while(Serial.available()) {
      character = Serial.read();
      content.concat(character);
      delay(10);
  }

  if (content != "") {
    Serial.println(content);
    int firstHashTag = content.indexOf('#');
    Serial.println(firstHashTag);
    if (content.substring(firstHashTag) == "#lock") {
      Serial.println("Locking doors");
    }
    if (content.substring(firstHashTag) == "#unlock") {
      Serial.println("Unlocking doors");
    }
  }
}
  while(Serial.available()) {
      character = Serial.read();
      content.concat(character);
      delay(10);   ///////////////// NO!!
  }

You risk losing characters by sending your Arduino to sleep here.

Read the input until a newline character - currently you read some random
number of characters and then treat it as the whole string - you should be
using a delimiter such as newline - read till the delimeter, then process the
string.

Do you have any tips on how to do that? I tried this...

while (Serial.available()) {
      character = Serial.read();
      if (character != "\r") {
        content.concat(character);
      }
  }

but the compiler fusses at me for comparing a pointer to an integer

String content = "" ;

void loop ()
{
  if (Serial.available ())
  {
    char ch = Serial.read () ;
    if (ch == '\n')
    {
      process_string (content) ;
      content = "" ;
    }
    else
      content.concat (ch) ;
  }
}

void process_string (String s)
{
  ......
}

That works, thank you!!

There's an easier way:

// your loop code...

int charsRead;
char message[25];    // ...or whatever your expected max chars is

   charsRead = Serial.readBytesUntil('\0', message, 24);   // Save room for the null
   message[charsRead] = '\0';     // Now it's a string
   // whatever you need to do...

The code reads the Serial object until: 1) it sees a newline characters ('\n') or 2) it has read 24 bytes. Get rid of the String class (note uppercase 'S'). It is convenient, but eats far too many resources. My guess is that using char arrays instead will save you at least 1K of memory.