-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvertstringtocamelcase.cpp
More file actions
44 lines (40 loc) · 1023 Bytes
/
Convertstringtocamelcase.cpp
File metadata and controls
44 lines (40 loc) · 1023 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
36
37
38
39
40
41
42
43
44
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include <string>
#include <sstream>
#include <climits>
using namespace std;
string to_camel_case(string text) {
string result;
for (int i = 0; i < text.size(); i++)
{
if (text[i] != '-' && text[i] != '_')
{
result += text[i];
}
else
{
result += toupper(text[i + 1]);
i++;
}
}
return result;
}
int main()
{
cout << to_camel_case("The-Stealth-Warrior");
return 0;
}
/*Description:
Complete the method/function so that it converts dash/underscore delimited words into camel casing.
The first word within the output should be capitalized only if the original word was capitalized (known as Upper Camel Case,
also often referred to as Pascal case). The next words should be always capitalized.
Examples
"the-stealth-warrior" gets converted to "theStealthWarrior"
"The_Stealth_Warrior" gets converted to "TheStealthWarrior"
"The_Stealth-Warrior" gets converted to "TheStealthWarrior"
Regular Expressions
Algorithms
Strings*/