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
42
S
19
G
65
Posts: 1,097
Reputation: 37,906

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
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

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
42
S
19
G
65
Posts: 1,097
Reputation: 37,906


Return to How do I....?

Who is online

Users browsing this forum: StillSarah and 22 guests