Arduino / SoftwareSerial/replacing ascii string

Hi - I'm new to programming and attempting to replace part of an input string with another string. I'm using a Uno with a CuteDigi Protosheild with a MAX233. I'm inputting/outputting a 9600 baud serial string ($OHPR,xxx.x,xxx.x,xx.x,xx.x*xx) thru the 233 into the Uno using SoftwareSerial.h thru D2 and out thru the USB serial port. I want to replace the beginning '$OPHR' with '$GPXDR'. I can print the sring and strip out the '*xx' but cant seem to figure out how to replace those beginning characters. Any input would be helpful.

Thank you

Assuming those strings are exact and don't vary, you can create a new string that is the length of the original + 1, and use strncpy() twice.

Hi - Thanks for the reply. The serial string data does change - the original string is heading, roll, pitch and temp. The $OHPR, does not change and this is what I'd like to replace with $GPXDR.

Do you need to replace it, or just print $GPXDR instead of $OHPR ?

char *in = "$OHPR,xxx.x,xxx.x,xx.x,xx.x*xx";

Serial.print("$GPXDR");
Serial.println(in+5); // Print from the 6th character (,)

dscott:
Hi - Thanks for the reply. The serial string data does change - the original string is heading, roll, pitch and temp. The $OHPR, does not change and this is what I'd like to replace with $GPXDR.

That's what I meant, if it's always going to start with "$OHPR", then you can use strncpy() to a new string. If you just wante to print it, use majenko's code.

Can you post your current code?