Replace "

hi I am trying to replace " with a 0

str2.replace('"',0 );

I how do I enter " as an asc character ?

thanks

Single quote around the zero, or use 48.

str2.replace('"','0' );
str2.replace('"',48);

jasemilly:
hi I am trying to replace " with a 0

str2.replace('"',0 );

I how do I enter " as an asc character ?

thanks

Try:

str2.replace("\"",0 );

I am trying to use the replace function on the variable str2 and store in str3 but encountering the above error. I don't understand the error. When I rem the replace line it works and the str2.substring works fine. How come substring works but replace wont????

thanks

 String str2(sunset);
  Serial.println(str2);
  
  String  str3 = str2.replace('"','0' );
  Serial.println(str3);
  Serial.println(str2.substring(9,23));

I don't understand the error.

You don't understand that the replace() method does not return a new String? Why not? The replace() method modifies the instance it is called for.

str2.replace('"','0' )

both the arguments to replace are single quoted ('...') denoting a single character.
Instead, use the double quotes ("...")

Thank you that worked :slight_smile:

I wonder what worked?