How to cut off part of a String?

Hi, I’ve been learning Arduino basics and would like to know how to cut off part of the string which is transferred via UART from my Android-phone to Arduino. I am using RoboRemo App and when I move a slider I see dfferent values on the serial monitor - from 0 to 255. But before integer value there is always a slider ID - how to cut this ID off? I would like to use this value as PWM to control a diode.

int led = 13;
String pwm = ""; 

void setup() 
{Serial1.begin(9600); 
pinMode(led,OUTPUT);
digitalWrite (led, LOW); 
} 

void loop() 
{ if(Serial1.available() > 0)
  {pwm = Serial1.readStringUntil('\n');
Serial.println(pwm);
analogWrite(led,50);
}}

MarJanPol:
But before integer value there is always a slider ID - how to cut this ID off?

subString()

Thank you!!!
m.

One more question - how to transfer String class value into integer value (int)?
Marek

Now the code looks like below, but (pwm.substring(3)) does't work as integer for PWM function and Arduino rejects that code.

int led = 13;
String pwm = "";

void setup()
{Serial1.begin(9600);
pinMode(led,OUTPUT);
digitalWrite (led, LOW);
}

void loop()
{ if(Serial1.available() > 0)
{pwm = Serial1.readStringUntil('\n');
Serial.println(pwm.substring(3));
analogWrite(led,(pwm.substring(3)));
}}

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example.

...R

Thank you Robin2 !!!
I will try this way.
m.