Variable path returns "/SDWebBrowse"; without the quotes.
How can I remove the character "/"; leaving SDWebBrowse?
Tried String exString = path, using the String exString ="Hello World'"example; without success.
Wm
Variable path returns "/SDWebBrowse"; without the quotes.
How can I remove the character "/"; leaving SDWebBrowse?
Tried String exString = path, using the String exString ="Hello World'"example; without success.
Wm
You could use something like readString.indexOf('/') to find the location of the /, then readString.substring() to capture everything beyond the /.
If you used strings instead of Strings, you'd just point to the second character.
No need to lose anything
Could you give an example, please?
static char MyBuffer[81];
void setup( void )
{
strcpy( MyBuffer, "/SDWebBrowse" );
Serial.begin( 115200 );
Serial.println( &MyBuffer[1] );
}
void loop( void ) { }
Very simple demo code using the serial monitor.
// zoomkat 3-19-15 serial string test
// type a string like yadayadayada/SDWebBrowse
// in serial monitor. then send or enter
String readString, newString;
void setup() {
Serial.begin(9600);
Serial.println("serial test parse"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
delay(2); //delay to allow byte to arrive in input buffer
char c = Serial.read();
readString += c;
}
if (readString.length() >0) {
Serial.println(readString);
int pos = readString.indexOf('/');
newString = readString.substring(pos+1);
Serial.print("newString is: ");
Serial.println(newString);
newString="";
readString="";
}
}
Thank you Coding Badly and zoomkat!
I will try both examples.