How do I use Regex to extract characters from string?

Get help using Construct 2

Post » Thu Mar 02, 2017 7:52 pm

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 == "")

cout << "\n\nThe acronym is \"" << acronym(str) << "\"" << "\n";


return 0;

string acronym(string str)
string phrase = "";

phrase = str[0];

for (int i = 0; i < str.length(); i++)
if (str[i] == ' ')
phrase += str[i+1];

return phrase;

Can anyone show me how to achieve this using Regex?
Posts: 5
Reputation: 210

Post » Thu Mar 02, 2017 8:31 pm

I don't think a regex is the solution. You should probably do something like this :
Posts: 984
Reputation: 19,503

Return to How do I....?

Who is online

Users browsing this forum: richcoz81, Yahoo [Bot] and 46 guests