arduino 截取 字符串 截取substring
String stringOne = "Content-Type: text/html";
Serial.println(stringOne);
// substring(index) looks for the substring from the index position to the end:
if (stringOne.substring(19) == "html") {
Serial.println("It's an html file");
}
// you can also look for a substring in the middle of a string:
if (stringOne.substring(14, 18) == "text") {
Serial.println("It's a text-based file");
字符串转成整型,string to int
String instring2="123e456y78a";
Serial.println(instring2.toInt()); //包含有英文,输出0
Serial.println(instring2.substring(2).toInt());//2
Serial.println(instring2.substring(0,3).toInt());//123
Serial.println(instring2.substring(4,7).toInt());//456
指定位置替换字符(char)
String reportString = "SensorReading: 456";
reportString.setCharAt(13, '=');//字符从0开始计算,左边开始计算
Serial.println(reportString);
作者:听我俩天
来源:CSDN
原文:https://blog.csdn.net/CSDN2016DDDD/article/details/80359865
版权声明:本文为博主原创文章,转载请附上博文链接!