0 Favourites

find() expression is not case-sensitive

  • Problem Description

    using find() expression is not case-sensitive. Because it isn't, you have to use more complicated methods to get the results you need. It'd be better if find() is case-sensitive.

    Attach a Capx

    http://1drv.ms/1PmPKxi

    Description of Capx

    text object has an instance variable holding a string ABCDabcd. find() is used to get index of "b", but it returns an index of 1 instead.

    Steps to Reproduce Bug

      run capx

    Observed Result

    It doesn't return the index of "b"

    Expected Result

    it should return an index of "b", which would be 5. It should be case-sensitive.

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (YES)

    Operating System and Service Pack

    vista sp2

    Construct 2 Version ID

    216

  • I don't think it should be case specific, unless you tell it to be.

    For that try regex.

  • having to use regex just to find the index is troublesome, because in some cases you might have to escape specific characters. If you can simply use find(), it would make the process simpler for users.

    I don't mind specifying whether to use case-sensitivity as long as there is the option to do so.

  • Then it's a feature request, and not really a bug.

    In the meantime you can use regex, or you can use comparisons using basic operators, string="b", string variable="B", etc.

    Btw text object compare text can be case sensitive.

  • I'd say it's a bug considering javascript's indexOf() is case-sensitive. There's no explanation or even mentioning why find() isn't case-sensitive in the manual. If someone wants to find where "string" is, and they have "strinG" before it, it will return the wrong index.

  • find() appears to be deliberately case insensitive, probably because most features in C2 are case insensitive too (e.g. matching animation names is case insensitive). I won't change it, since it could break compatibility with existing projects. For the next build I've added a new findCase() system expression which works identically but is case sensitive. I'll update the documentation to reflect this as well (which normally we do just before the next stable release).

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Thanks!

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