0 Favourites

How do I RegexReplace

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

    [quote:152tky13]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.

    Edit:

    @IndieKiwi

    maybe you can help me?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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:

    Condition: LevelNumber > 0
    Action: System > Go to Layout by name LevelNumber (without brackets!)
    [/code:36fqp8db]
    
    If you still need a regex solution ask me, but this is not needed I am sure.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,127
karshinkoff's avatar
karshinkoff
Unread hot topic
56 4,727
MPPlantOfficial's avatar
MPPlantOfficial
Unread hot topic
0 Favourites
Why is Stencyl doing better?
44 16,851
Potato's avatar
Potato