DEV Community

Esther mueni
Esther mueni

Posted on

Arduino subString() function

I had to use substring to parse information from software Serial. here is what I learned.

Syntax::
myString.subString(from)
myString.subString(from, to)

This function is used to search for a specific substring in a string, 'myString'.
The search is inclusive of the from index but exclusive of the to.
When you use from without the to, it will search from the index indicated to the end of the string.

Example:
String me = "essy here now"
return me.subString(8);

This will return 'now' as it is the substring in the eight index till the end of the sentence.

'String me = "essy here now"
return me.subString(4,9);

This returns 'here'.

Top comments (0)