How do I remove the file extension from a string?

0 favourites
  • 3 posts
From the Asset Store
Customize the animation of character when item changed
  • Hello,

    I'm using an array to store the names of lots of different sprites. The user is able to change the sprites using the file chooser and then the file name amends the array as a new description of the sprite.

    I've got this working well although I cannot figure out how to remove the file extension from the string when the sprite is changed.

    At the moment I have:

    File Choooser > On Changed > Array > Set Value at 0 to FileChooser.FileNameAt(0)

    If anyone could advise how i can get the filename added to the Array without the .png or .jpeg extension I would really appreciate it!

    Many thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could try it with 'tokenat'.

    tokenat(src, index, separator)

    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

    Something like:

    File Choooser > On Changed > Array > Set Value at 0 to tokenat(FileChooser.FileNameAt(0),0,".")

  • Hey Asmodean,

    That did the trick! Thank you ever so much :)

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