[SOLVED]How do I compare special characters.

0 favourites
From the Asset Store
A collection of various soldier character sprites for creating a 2D platformer or sidescroller game
  • It's a test for a match. So you need a "Test Regex" condition. The String parameter is your letter, the Regex parameter is "^[!@#$%?&*()]$" and the flags are irrelevant in this case so you can leave it empty.

    If it works by removing those characters (^ and $) it's because you aren't testing the Regex with a single character. ^ means "match beginning" and $ means "match end". So along with the rest of the patterns, the Regex test if the String is a single character that is either one of those inside the brackets.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • yeah it is much clearer now. I am at the point now where if it ain't broke don't fix it. Thanks for the explanation!

  • mattshallow

    The capx you shared somehow got corrupted - there is no Files subfolder in it. So I had to manually add mmd_all_letters.txt with this content:

    a;b;c;d;e;f;$;@;#;%;&;^;*

    But after that the condition letterText text is "$" worked for me. The variable is increased by 4 and progress bar changes when I add $ to the password.

    You can actually get rid of the txt file and AJAX, just store all letters in a text variable. And no need to separate letters with ";", use mid(allLetters, loopindex,1)

  • [quote:3ko9lbit]But after that the condition letterText text is "$" worked for me

    Did you toggle off the lowercase and uppercase events below it? Because special characters are considered as lower and uppercase also. If they are off the statement does not work for me.

    [quote:3ko9lbit]You can actually get rid of the txt file and AJAX, just store all letters in a text variable

    That's true. I am just trying to get familiar with construct 2 features. I will eventually have a save and load file so I might need AJAX for that.

  • Just to clarify, I do have it working using regex search and having the other two events as else statements

    check if special char

    else

    check if lower case

    else

    check if uppercase

  • Did you toggle off the lowercase and uppercase events below it? Because special characters are considered as lower and uppercase also. If they are off the statement does not work for me.

    Special characters can't be lower or upper case, so it doesn't matter if you select "case sensitive" or "ignore case", and uppercase()/lowercase() expressions do nothing with them.

    All these 3 events work fine for me:

  • [quote:3d8jrzzl]Special characters can't be lower or upper case

    For me they are being detected under both. So if I toggle off my Regex expression without the else statements, the special char will be read into both upper and lowercase.

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