How to use find() with case-sensitive?

Get help using Construct 2

Post » Tue Nov 10, 2015 2:04 am

If I use find() to try and find "a", it will return "A" if it is ahead of the "a".
How do I ensure it finds "a" instead of "A"?
B
49
S
23
G
66
Posts: 1,151
Reputation: 39,103

Post » Tue Nov 10, 2015 4:51 am

You could use a regex search i suppose. Find in C2 uses a regex.
You could also use the javascript "indexOf" to do it. It's case sensitive.

global text variable="Aa"

start of layout
> Text: set text to Browser.execJS("'"&variable&"'.indexOf('a')")
B
95
S
34
G
128
Posts: 5,494
Reputation: 81,676

Post » Tue Nov 10, 2015 5:25 am

Thanks..
I had to escape some characters to make it work with execJS (since I need to find other characters), so I added string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, ""\\$&"");
It was creating errors otherwise.
B
49
S
23
G
66
Posts: 1,151
Reputation: 39,103


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 11 guests