How do I RegexReplace

Get help using Construct 2

Post » Fri Jan 23, 2015 8:35 am

I'm having a bit of trouble understanding and using this

RegexReplace(String, Regex, Flags, Replace)
In String substitute matches for the regular expression Regex (with Flags) with the string Replace. The replacement string can contain the following special characters: $$ (inserts a $), $& (inserts the matched substring), $` (inserts the portion of the string that precedes the matched substring), or $' (inserts the portion of the string that follows the matched substring).

I have a global variable called LevelNumber and my layouts are named Level 001, Level 002, Level 003, and so on.

I want a single event that will detect LevelNumber and go to layout (by name)

Condition: LevelNumber > 0
Action: Go to Layout "RegexReplace ( LevelNumber, don't know what to put here, don't know what to put here, "Level 00")

Help please. Thanks in advance.

maybe you can help me?
Posts: 301
Reputation: 2,736

Post » Sun Jan 25, 2015 4:22 pm

You can just name your layouts 001, 002 instead of Level 001 etc. This is simple and saving CPU, regex need more. I am not sure how 001 is count, maybe just as 1, but better to name layout 1,2,3 etc. Then you can display text like a

"level "&LayoutName

or something.

And code you need:

Code: Select all
Condition: LevelNumber > 0
Action: System > Go to Layout by name LevelNumber (without brackets!)

If you still need a regex solution ask me, but this is not needed I am sure.
Posts: 30
Reputation: 594

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests