How do I trim using Regular expression

0 favourites
  • 3 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hello,

    I want to trim the TIME out of this STRING using regular expression.

    I'm using Text set text = BROWSER behaviour on EveryTick.

    TEXT | set text = trim(left(Browser.ExecJS("Date()"),30))

    RESULT: Tue Oct 13 2020 12:09:04

    I only want the time = 12:09:04

    If I try trim(right .... I get something completely different.

    Can anyone please help?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I assume the "trim(right .... I get something completely different" means you are seeing the timezone. Your result probably doesn't show it because the text area you set up is too small but if you extended that out you would see something like:

    Tue Oct 13 2020 09:24:49 GMT-0

    If you shrink the size of your left command to just the first 24 characters, you don't get the timezone.

    Try this:

    TEXT | set text = right(trim(left(Browser.ExecJS("Date()"),24)),8)

    This does exactly what you have already figured out, except only getting the first 24 characters, but then gets just the 8 characters on the right side.

  • Thanks Amigo - you're the best!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)