regexstringactionscript-3escapingflash-cs6

How to remove an apostrophe and a space from my string (AS3 Flash CC possibly regex)?


I have a string that goes in a textfield. This string comes from an xml-file. This string is also the name of an mp3 I call when people click on the textfield.

The strings are in Dutch (because it's for a Dutch program) and my language has certain words that are written like this: 's nachts. So you have an apostrophe, an s, a space and a word (basically it means at night).

Because you can't have audiofiles starting with an apostrophe, I would like to convert the string 's nachts to snachts. That way I can call on snachts.mp3.

I would love to be able to regex this, but I don't know enough about it to do so.


Solution

  • For something this simple, you probably don't need to use a regular expression. Something like this should work:

    myString = myString.replace("'s ", "s");
    

    Of course it could be a regular expression, like this:

    myString = myString.replace(/'s /g, "s");