How do I RegexReplace

0 favourites
  • 2 posts
  • 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?

  • Try Construct 3

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

    Try 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)