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
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

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
94
S
33
G
117
Posts: 5,390
Reputation: 75,341

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
48
S
23
G
66
Posts: 1,144
Reputation: 39,059


Return to How do I....?

Who is online

Users browsing this forum: avatar45 and 4 guests