|
@@ -15,7 +15,8 @@ public class StringParser
|
15
|
15
|
*/
|
16
|
16
|
public static String upperCaseString(String s)
|
17
|
17
|
{
|
18
|
|
- return null;
|
|
18
|
+
|
|
19
|
+ return s.toUpperCase();
|
19
|
20
|
}
|
20
|
21
|
|
21
|
22
|
/**
|
|
@@ -26,7 +27,7 @@ public class StringParser
|
26
|
27
|
* @return String
|
27
|
28
|
*/
|
28
|
29
|
public static String lowerCaseString(String s) {
|
29
|
|
- return null;
|
|
30
|
+ return s.toLowerCase();
|
30
|
31
|
}
|
31
|
32
|
|
32
|
33
|
/**
|
|
@@ -37,7 +38,9 @@ public class StringParser
|
37
|
38
|
* @return String
|
38
|
39
|
*/
|
39
|
40
|
public static Character getFirstCharacter(String s) {
|
40
|
|
- return null;
|
|
41
|
+ char firstLetter = s.charAt(0);
|
|
42
|
+
|
|
43
|
+ return firstLetter;
|
41
|
44
|
}
|
42
|
45
|
|
43
|
46
|
/**
|
|
@@ -49,7 +52,9 @@ public class StringParser
|
49
|
52
|
* @return String
|
50
|
53
|
*/
|
51
|
54
|
public static Character getNthCharacter(String s, Integer n) {
|
52
|
|
- return null;
|
|
55
|
+ char nLetter = s.charAt(n);
|
|
56
|
+
|
|
57
|
+ return nLetter;
|
53
|
58
|
}
|
54
|
59
|
|
55
|
60
|
/**
|
|
@@ -60,7 +65,9 @@ public class StringParser
|
60
|
65
|
* @return String
|
61
|
66
|
*/
|
62
|
67
|
public static String upperCaseFirstCharacter(String s) {
|
63
|
|
- return null;
|
|
68
|
+ String firstLetterUpper = s.substring(0,1).toUpperCase() + s.substring(1);
|
|
69
|
+
|
|
70
|
+ return firstLetterUpper;
|
64
|
71
|
}
|
65
|
72
|
|
66
|
73
|
/**
|
|
@@ -72,7 +79,23 @@ public class StringParser
|
72
|
79
|
* @return String
|
73
|
80
|
*/
|
74
|
81
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
82
|
+ String st = s.toLowerCase();
|
|
83
|
+ String[] arr = st.split(" ");
|
|
84
|
+ StringBuffer sb = new StringBuffer();
|
|
85
|
+
|
|
86
|
+ for (int i = 0; i < arr.length; i++) {
|
|
87
|
+ sb.append(Character.toUpperCase(arr[i].charAt(0)))
|
|
88
|
+ .append(arr[i].substring(1));
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+ String a = sb.toString();
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+ return a;
|
|
98
|
+
|
76
|
99
|
}
|
77
|
100
|
|
78
|
101
|
/**
|
|
@@ -84,7 +107,11 @@ public class StringParser
|
84
|
107
|
* @return String
|
85
|
108
|
*/
|
86
|
109
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
110
|
+ String lower = s.toLowerCase();
|
|
111
|
+ String a = lower.replaceAll("\\s","_");
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+ return a;
|
88
|
115
|
}
|
89
|
116
|
|
90
|
117
|
/**
|
|
@@ -95,7 +122,7 @@ public class StringParser
|
95
|
122
|
* @return String
|
96
|
123
|
*/
|
97
|
124
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
125
|
+ return s.length();
|
99
|
126
|
}
|
100
|
127
|
|
101
|
128
|
/**
|
|
@@ -109,7 +136,11 @@ public class StringParser
|
109
|
136
|
* @return String
|
110
|
137
|
*/
|
111
|
138
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
139
|
+ if(s1.equals(s2)){
|
|
140
|
+ return true;
|
|
141
|
+ }else{
|
|
142
|
+ }
|
|
143
|
+ return false;
|
113
|
144
|
}
|
114
|
145
|
|
115
|
146
|
/**
|
|
@@ -123,6 +154,16 @@ public class StringParser
|
123
|
154
|
* @return String
|
124
|
155
|
*/
|
125
|
156
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+ if(s1.equalsIgnoreCase(s2)){
|
|
163
|
+ return true;
|
|
164
|
+ }else {
|
|
165
|
+ }
|
|
166
|
+ return false;
|
|
167
|
+
|
127
|
168
|
}
|
128
|
169
|
}
|