How to get data from 9DOF razor IMU directly to arduino mega
sscanf should be enough. There is also other options, String class for example with substring method.

Take a look at the example: 

#include &lt;stdio.h&gt;

char myString[] = "#YPR=72.13,1.74,-16.38";

void setup() {
  // put your setup code here, to run once:
  float yaw = 0;
  float pitch = 0;
  float roll = 0;

  sscanf(myString, "#YPR=%f,%f,%f", &amp;yaw, &amp;pitch, &amp;roll);
  Serial.println(yaw);
  Serial.println(pitch);
  Serial.println(roll);
}

void loop() {


}