String st1 = "Al-Huson";
String st2 = "College";
char buffer[10];
String X = "13,45";
String Y = "12345";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// Characte(st1, st2);
//Compares(st1, st2);
//Concat(st1, st2);
//EndsWith(st1, st2);
//Equals(st1, st2);
//EqualsIgnoreCase(st1, st2);
//getBytes(st1, st2);
//IndexOf(st1, st2);
//LastIndexOf(st1, st2);
// Length(st1, st2);
//Remove(st1, st2);
// Remove2(st1, st2);
//Replace(st1, st2);
//Reserve(st1, st2);
//SetCharAt(st1, st2);
//startsWith(st1, st2);
//substring(st1, st2);
//substring2(st1, st2);
//toCharArray(st1, st2);
//toFloat(X, Y);
//toInt(X, Y);
//toLowerCase(st1, st2);
// toUpperCase(st1, st2);
trim(st1, st2);
}
void loop() {
// put your main code here, to run repeatedly:
}
//Returns the nth character of the String
void Characte(String st1, String st2){
Serial.println(st1.charAt(1));
Serial.println(st2.charAt(1));
}
//Compares the String to the given String S2
void Compares(String st1, String st2){
Serial.println(st1.compareTo(st2));
Serial.println(st2.compareTo(st1));
Serial.println(st1.compareTo(st1));
}
//Returns a new String that is the combination of the String and S2
void Concat(String st1, String st2){
st1.concat(st2);
Serial.println(st1);
}
//Returns true if the String ends with the characters of S2
void EndsWith(String st1, String st2){
Serial.println(st1.endsWith("son"));
Serial.println(st1.endsWith("c"));
}
//Returns true if the String is an exact match for S2 (case-sensitive)
void Equals(String st1, String st2){
Serial.println(st1.equals(st2));
}
//Same as equals but is not case-sensitive
void EqualsIgnoreCase(String st1, String st2){
Serial.println(st1.equalsIgnoreCase(st2));
}
//Copies len(gth) characters into the supplied byte buffer
void getBytes(String st1, String st2){
st1.getBytes(buffer,7);
Serial.println(st1);
st2.getBytes(buffer,7);
Serial.println(st2);
}
//Returns the index of the supplied String (or character) or –1 if not found
void IndexOf(String st1, String st2){
Serial.println(st1.indexOf('l'));
Serial.println(st2.indexOf('g'));
}
//Same as indexOf but starts from the end of the String
void LastIndexOf(String st1, String st2){
Serial.println(st1.lastIndexOf('l'));
Serial.println(st2.lastIndexOf('g'));
}
//Returns the number of characters in the String
void Length(String st1, String st2){
Serial.println(st1.length());
Serial.println(st2.length());
}
//Removes the character in the String at the given index
void Remove(String st1, String st2){
st1.remove(3);
Serial.println(st1);
st2.remove(3);
Serial.println(st2);
}
//Removes the specified number of characters from the String starting at the given index
void Remove2(String st1, String st2){
st1.remove(2,5);
Serial.println(st1);
st2.remove(2,2);
Serial.println(st2);
}
//Replaces all instances of String (or character) A with B
void Replace(String st1, String st2){
st1.replace('s','o');
Serial.println(st1);
st2.replace('e','l');
Serial.println(st2);
}
//Sets aside (allocates) the specified number of bytes to make subsequent Stringoperations more efficient
void Reserve(String st1, String st2){
Serial.println(st1.reserve(50));
Serial.println(st2.reserve(50));
}
//Stores the character c in the String at the given index
void SetCharAt(String st1, String st2){
st1.setCharAt(3,'x');
Serial.println(st1);
st2.setCharAt(3,'x');
Serial.println(st2);
}
//Returns true if the String starts with the characters of S2
void startsWith(String st1, String st2){
Serial.println(st1.startsWith("A"));
Serial.println(st2.startsWith("c"));
}
//Returns a String with the characters starting from index to the end of the String
void substring(String st1, String st2){
Serial.println(st1.substring(5));
Serial.println(st2.substring(5));
}
//Same as above, but the substring ends at the character location before the to position
void substring2(String st1, String st2){
Serial.println(st1.substring(2,6));
Serial.println(st2.substring(2,6));
}
//Copies up to len characters of the String to the supplied buffer
void toCharArray(String st1, String st2){
st1.toCharArray(buffer,7);
Serial.println(st1);
st2.toCharArray(buffer,7);
Serial.println(st2);
}
//Returns the floating-point value of the numeric digits in the String
void toFloat(String X, String Y){
Serial.println(X.toFloat());
Serial.println(Y.toFloat());
}
//Returns the integer value of the numeric digits in the String
void toInt(String X, String Y){
Serial.println(X.toInt());
Serial.println(Y.toInt());
}
//Returns a String with all characters converted to lowercase
void toLowerCase(String st1, String st2){
st1.toLowerCase();
Serial.println(st1);
st2.toLowerCase();
Serial.println(st2);
}
//Returns a String with all characters converted to Uppercase
void toUpperCase(String st1, String st2){
st1.toUpperCase();
Serial.println(st1);
st2.toUpperCase();
Serial.println(st2);
}
//Returns a String with all leading and trailing whitespace removed
void trim(String st1, String st2){
st1.trim();
Serial.println(st1);
st2.trim();
Serial.println(st2);
}