-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString.cpp
More file actions
147 lines (112 loc) · 4.35 KB
/
String.cpp
File metadata and controls
147 lines (112 loc) · 4.35 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// MIT License
// Copyright (c) 2025 Abiza Chiheb
// See the LICENSE file for full details.
#include <iostream>
#include "clsString.h"
using namespace std;
int main()
{
clsString String1;
clsString String2("Chiheb");
String1.SetValue("Ali Ahmed");
cout << "String1 = " << String1.GetValue() << endl;
cout << "String2 = " << String2.GetValue() << endl;
cout << "Number of words: " << String1.CountWords() << endl;
cout << "Number of words: " << String1.CountWords("Fadi ahmed rateb omer") << endl;
cout << "Number of words: " << clsString::CountWords("chiheb mohammed abiza") << endl;
//----------------
clsString String3("hi how are you?");
cout << "String 3 = " << String3.GetValue() << endl;
cout << "String Length = " << String3.Length() << endl;
String3.UpperFirstLetterOfEachWord();
cout << String3.GetValue() << endl;
//----------------
String3.LowerFirstLetterOfEachWord();
cout << String3.GetValue() << endl;
//----------------
String3.UpperAllString();
cout << String3.GetValue() << endl;
//----------------
String3.LowerAllString();
cout << String3.GetValue() << endl;
//----------------
cout << "After inverting a : "
<< clsString::InvertLetterCase('a') << endl;
//----------------
String3.SetValue("AbCdEfg");
String3.InvertAllLettersCase();
cout << String3.GetValue() << endl;
String3.InvertAllLettersCase();
cout << String3.GetValue() << endl;
//----------------
cout << "Capital Letters count : "
<< clsString::CountLetters("Chiheb abiza", clsString::CapitalLetters)
<< endl
<< endl;
//----------------
String3.SetValue("Welcome to Algeria");
cout << String3.GetValue() << endl;
cout << "Capital Letters count :" << String3.CountCapitalLetters() << endl;
//----------------
cout << "Small Letters count :" << String3.CountSmallLetters() << endl;
//----------------
cout << "vowels count :" << String3.CountVowels() << endl;
//----------------
cout << "letter E count :" << String3.CountSpecificLetter('E', false) << endl;
//----------------
cout << "is letter u vowel? " << clsString::IsVowel('a')
<< endl;
//----------------
cout << "Words Count" << String3.CountWords()
<< endl;
//----------------
vector<string> vString;
vString = String3.Split(" ");
cout << "\nTokens = " << vString.size() << endl;
for (string &s : vString)
{
cout << s << endl;
}
//----------------
// Tirms
String3.SetValue(" Chiheb abiza ");
cout << "\nString = " << String3.GetValue();
String3.SetValue(" Chiheb abiza ");
String3.TrimLeft();
cout << "\n\nTrim Left = " << String3.GetValue();
//----------------
String3.SetValue(" Chiheb abiza ");
String3.TrimRight();
cout << "\nTrim Right = " << String3.GetValue();
//----------------
String3.SetValue(" Chiheb abiza ");
String3.Trim();
cout << "\nTrim = " << String3.GetValue();
//----------------
// Joins
vector<string> vString1 = {"Mohammed", "Faid", "Ali", "Maher"};
cout << "\n\nJoin String From Vector: \n";
cout << clsString::JoinString(vString1, " ");
string arrString[] = {"Mohammed", "Faid", "Ali", "Maher"};
cout << "\n\nJoin String From array: \n";
cout << clsString::JoinString(arrString, 4, " ");
//----------------
String3.SetValue("Chiheb setif abiza");
cout << "\n\nString = " << String3.GetValue();
String3.ReverseWordsInString();
cout << "\nReverse Words : " << String3.GetValue()
<< endl;
//---------------
String3.SetValue("Chiheb algeria abiza");
cout << "\nReplace : " << String3.ReplaceWord("Mohammed", "Sari")
<< endl;
//---------------
String3.SetValue("This is: a sample text, with punctuations.");
cout << "\n\nString = " << String3.GetValue();
String3.RemovePunctuations();
cout << "\nRemove Punctuations : " << String3.GetValue()
<< endl;
//---------------
system("pause");
return 0;
}