[Solved] How to prepend a word with a letter if the first letter of that word is upper-case?

Using a regex: string paragraphWord = “This is A String of WoRDs”; var reg = new Regex(@”(?<=^|\W)([A-Z])”); Console.WriteLine(reg.Replace(paragraphWord,”k$1″)); Explaining (?<=^|\W)([A-Z]) ?<= positive look behind ^|\W start of the string or a whitespace character [A-Z] A single upper case letter So we are looking for a single upper case letter proceeded by either the start of … Read more

[Solved] A dictionary that returns number of word and each word’s lenght Python

sample = “i am feeling good” output = {} output[“word”] = len(sample.split()) output[“chars”] = len(list(sample)) for elem in sample.split(): output[elem] = len(list(elem)) print(output) output: {‘word’: 4, ‘chars’: 17, ‘i’: 1, ‘am’: 2, ‘feeling’: 7, ‘good’: 4} solved A dictionary that returns number of word and each word’s lenght Python

[Solved] Count equal strings in a list of string and make them unique

This can be done with Linq and the GroupBy function pretty easily: var input = new string[] { “welcome guys”, “guys and”, “and ladies”, “ladies repeat”, “repeat welcome”, “welcome guys” }; var groups = input .GroupBy(x => x); foreach (var g in groups) { Console.WriteLine(“{0}, {1}”, g.Key, g.Count().ToString()); } welcome guys, 2 guys and, 1 … Read more

[Solved] Converting number into word

Try this : ten_thousand = number/10000; number = number%10000; thousand = number/1000; number = number%1000; hundred = number/100; number = number%100; ten = number/10; number = number%10; unit = number; solved Converting number into word

[Solved] Reaching the 3rd word in a string [duplicate]

The most straightforward way: #include <iostream> int main() { //input string: std::string str = “w o r d 1\tw o r d2\tword3\tword4”; int wordStartPosition = 0;//The start of each word in the string for( int i = 0; i < 2; i++ )//looking for the third one (start counting from 0) wordStartPosition = str.find_first_of( ‘\t’, … Read more