Hello all,
I'm developing 4 video games to help build cyber security awareness among high-school kids. For one game I'm taking them thru a series of steps which help them in creating a strong password. One of the steps requires them to enter the acronym of the phrase they entered initially and I need a way for the game to validate if they entered the correct acronym before allowing them to move forward.
Basically I'm trying to write a function to "acronymize" text entered into a textbox by the user via the keyboard.
For example, if the user enters the phrase "hey what's cooking good looking", initially, this text is saved to text variable say "UserPhrase", then the user is prompted to enter the acronym of this phrase, the game/function should compute the acronym of this stored phrase and compare it to the acronym entered by the user, if it is correct, a corresponding text object should display the result which in this case would be "hwcgl" and allow the user to move forward in the game.
I know how to carry this out in C++ but I am having a high degree of difficulty translating it to Construct 2.
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
string acronym(string str);
int main()
{
string str;
while (true)
{
cout << "\nPlease enter a string: ";
getline(cin, str);
if (str == "")
{
break;
}
cout << "\n\nThe acronym is \"" << acronym(str) << "\"" << "\n";
}
system("PAUSE");
return 0;
}
string acronym(string str)
{
string phrase = "";
phrase = str[0];
for (int i = 0; i < str.length(); i++)
{
if (str == ' ')
{
phrase += str[i+1];
}
}
return phrase;
}
Can anyone show me how to achieve this using Regex?