How do I block the Space key?

0 favourites
  • 10 posts
From the Asset Store
Spaces Ambience contains 102 Sounds: 53 track and 49 sounds
  • Hi again

    i have this events to set a minimum of 3 characters length and a maximum of 15

    the thing is that i dont want to have Spaces, is there a way to block it? even if someone Paste a string with Spaces on it? or to not count the Blank Spaces as a char?

    what im trying to do is to verify the textbox has more than 3 characters but i dont want to count the blank spaces...

    any ideas?

    thanks again

  • You can use the regex system expressions.

    Remove all spaces from string ("\s" matches any whitespace, "g" = global, replaces all occurences):

    RegexReplace(TextBox.Text, "\s", "g", "")[/code:2ddr5qdt]
    
    Count number of spaces:
    [code:2ddr5qdt]RegexMatchCount(TextBox.Text, "\s", "g")[/code:2ddr5qdt]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Remove all spaces from string ("\s" matches any whitespace, "g" = global, replaces all occurences):

    ramones where did you find a list of the flags? I can't find it anywhere. The doc on this is ridiculously thin..

    do you know how to concat the flags together? if I wanted to remove whitespaces and "-" dashes? or do I have to do it as separate Actions? I actually want to remove all non alphas... is there a flag for that?

  • > Remove all spaces from string ("\s" matches any whitespace, "g" = global, replaces all occurences):

    >

    >

    ramones where did you find a list of the flags? I can't find it anywhere. The doc on this is ridiculously thin..

    do you know how to concat the flags together? if I wanted to remove whitespaces and "-" dashes? or do I have to do it as separate Actions? I actually want to remove all non alphas... is there a flag for that?

    What?

    Google "regex" will give you more results than you ever can read...

    http://eloquentjavascript.net/09_regexp.html

  • I'm sure he meant in C2 / the manual. But yeah regular expressions can be used in most programming languages and there are lots of guides out there.

  • RegExr is an online tool to learn, build, & test Regular Expressions(RegEx / RegExp).

  • For this you don't even need regex necessarily.

    replace(srctxt, " ", "")

    and if you wanna find out the length without spaces:

    len(replace(srctxt, " ", ""))

    Of course regex has it's advantage. It can also catch other whitespace characters in one go and replace them for you etc, like Ramones showed.

  • What?

    Google "regex" will give you more results than you ever can read...

    http://eloquentjavascript.net/09_regexp.html

    oh javascript.. that was not clear. I'm a C/C++ person I haven't done much js. Still there should be a link in the doc to something like this and not assume users know the flags or know it's js.

  • RegExr is an online tool to learn, build, & test Regular Expressions(RegEx / RegExp).

    oh it's not js? it is it's own thing? well it's a standard I know nothing about, so good to know!

  • okay so these..

    \d Any digit character

    \w An alphanumeric character (“word character”)

    \s Any whitespace character (space, tab, newline, and similar)

    \D A character that is not a digit

    \W A nonalphanumeric character

    \S A nonwhitespace character

    . Any character except for newline

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