endsWith() offset hinted at but doesn't exist?

I'm trying to get the 4th to last character of a string based on an offset using endsWith() - the tutorial http://arduino.cc/en/Tutorial/StringStartsWithEndsWith seems to indicate that similar to startsWith() I should be able to indicate an offset after the character I am looking for, i.e. endsWith("h",3) to see if the 4th to last character is the letter h.

The particular line that lead me to believe this should be possible is:

startsWith() and endsWith() can be used to look for a particular message header, or for a single character at the end of a String. They can also be used with an offset to look for a substring starting at a particular position.

Stealing from and modifying the example, this will fail to compile:

void setup() {
  Serial.begin(9600);
  Serial.println("\n\nString startsWith() and endsWith():");

}


void loop() {
  
  // you can look for startsWith() at an offset position in the string:
     String stringOne = "HTTP/1.1 200 OK";
  if (stringOne.startsWith("200 OK", 9)) {
    Serial.println("Got an OK from the server"); 
  } 
  
  // why cant I use endsWith() at an offset position in the string too:
     stringOne = "HTTP/1.1 200 OK";
  if (stringOne.endsWith("HTTP/1.1", 6)) {
    Serial.println("The request was HTTP"); 
  } 

// do nothing while true:
 while(true);
}

I'm assuming there is some fundamental reason about the way substring/indexing looks through strings and why this doesn't work, however, if that's the case then the example is a bit misleading.

Looking at the source:

unsigned char String::startsWith( const String &s2, unsigned int offset ) const
{
	if (offset > len - s2.len || !buffer || !s2.buffer) return 0;
	return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0;
}

unsigned char String::endsWith( const String &s2 ) const
{
	if ( len < s2.len || !buffer || !s2.buffer) return 0;
	return strcmp(&buffer[len - s2.len], s2.buffer) == 0;
}

Shows endsWith() only takes a single parameter.

dxw00d, thanks for checking into that. For any other hapless soul who believed like me that you could throw an offset into endsWith(), simply do an extra operation on startsWith to create the offset dynamically depending on the string's length, i.e.

void setup() {
  Serial.begin(9600);
  Serial.println("\n\nString startsWith()");

}


void loop() {
  
  // you can look for startsWith() at an offset position in the string and throw in string length to get to the end chars if you don't know how long it is:
     String stringOne = "HTTP/1.1 200 OK";
  if (stringOne.startsWith("OK", stringOne.length() - 2)) {
    Serial.println("Got an OK from the server"); 
  } 

}

Although this reads in the opposite direction than what I indicated my impression above, it does the job well.

I'm trying to get the 4th to last character of a string based on an offset using endsWith()

If you explicitly want the 4th to last character, get the String length, and use charAt() to get the character.

Then, perform a simple comparison:

char fourthFromEnd = someString.charAt(someString.length()-4);
if(fourthFromEnd == 'A') // Or whatever letter you are looking for
{
}