-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFlowerPlatformStringManip.h
More file actions
67 lines (56 loc) · 1.45 KB
/
FlowerPlatformStringManip.h
File metadata and controls
67 lines (56 loc) · 1.45 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Author: Anca Barbu
*/
#ifndef FlowerPlatformStringManip_h
#define FlowerPlatformStringManip_h
String changeCaseOfString(String s, String caseMode) {
String result = s;
if (caseMode == "lower") {
result.toLowerCase();
} else if (caseMode == "upper") {
result.toUpperCase();
}
Serial.println(s);
Serial.println(result);
return result;
}
String getTrimmedString(String s) {
String result = s;
result.trim();
return result;
}
String getReplacedString(String text, String what, String with) {
String result = text;
result.replace(what, with);
return result;
}
//TODO when we add suport for lists, it needs to be modified
/*String* splitText(String text, String delim) {
String copyText = text;
int c, found = 0;
while ( (c = copyText.indexOf(delim)) != -1) {
found ++;
copyText = copyText.substring(c + delim.length() , copyText.length());
}
String result[found];
int pos, i = 0;
copyText = text;
for (i = 0; i < found; i++) {
pos = copyText.indexOf(delim);
result[i] = copyText.substring(0, pos);
copyText = copyText.substring(pos + delim.length(), copyText.length());
}
result[found] = copyText;
return result;
}
//TODO when we add suport for lists, it needs to be modified
String* splitTextAtFirst(String text, String delim) {
String result[2];
int c;
if ( (c = text.indexOf(delim)) != -1) {
result[0] = text.substring(0, c);
result[1] = text.substring(c + delim.length(), text.length());
}
return result;
}*/
#endif