-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathStringSplitter_Example.ino
More file actions
35 lines (25 loc) · 975 Bytes
/
Copy pathStringSplitter_Example.ino
File metadata and controls
35 lines (25 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
StringSplitter example: Basic
This example shows how to split a delimited string to substrings (items) by using the StringSplitter library.
The output is visible in the Serial Monitor.
For more details see: https://github.com/aharshac/StringSplitter
*/
#include "StringSplitter.h"
void setup() {
Serial.begin(9600);
Serial.println(F("StringSplitter Library Test"));
String strTest = "123,456,789,abc";
Serial.println("Test String: " + strTest);
StringSplitter *splitter = new StringSplitter(strTest, ',', 3); // new StringSplitter(string_to_split, delimiter, limit)
int itemCount = splitter->getItemCount();
Serial.println("Item count: " + String(itemCount));
for(int i = 0; i < itemCount; i++){
String item = splitter->getItemAtIndex(i);
Serial.println("Item @ index " + String(i) + ": " + String(item));
}
Serial.println(F("End of program."));
Serial.end();
}
void loop() {
// put your main code here, to run repeatedly:
}