Remove word from a string

0 favourites
  • 7 posts
From the Asset Store
Customize the animation of character when item changed
  • Well didn't expect this to be so difficult

    This doesn't really work

    replace(Text.Text, tokenat(Text.Text, 0, " "), "")

    If I use replace it removes all the same tokens. So I think I should use RegexReplace.

    But I don't quite understand what this means

    [quote:2diyooig]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).

  • This seems to work

    RegexReplace(text.Text , "^\S+\s" , "g" , "") [/code:1bl42qvk]
    Still not sure what the flag does though
  • ^\S+\s means a line which starts with one or many non white-space character followed by one white-space character (but I think you got that one)

    g (global) means you want to replace all the occurence of your regex. Without it would only match the first one.

    However in your case, since you're not using the m flag (multi-line), even if your text contains line break, ^ will only consider the begining of the entire string (whith m it considers each line one by one).

    So the g flag is useless since you'll only ever have one occurrence matching.

    more info over there

  • Ok remove first word works but how about if I would like to remove word by it's serial number.

    I would use this in a RTS build queue variable that could look something like this "1 1 14 24" and this would be handy if the player wants to cancel some units.

    I have watched all kinds of guides but cannot seem to wrap my head around it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Maybe it would be simpler to use an array rather than writing strings?

  • SHOMOFO, Already did just that

  • Katala (^_^)

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