# How do I change the last letter in text?

Get help using Construct 2

### » Mon Sep 07, 2015 3:43 pm

Good morning. I hope what I am trying to do is possible...

Sprite.X has four variables.
Variable 1 = P11T1
Variable 2 = P02T1
Variable 3 = B01T1
Variable 4 = D08T1

The action I want is this...

If Variable 1 ends in "T1"
and If Variable 2 ends in "T1"
and If Variable 3 ends in "T1"
and If Variable 4 ends in "T1"
then choose randomly Variable 1, Variable 2, Variable 3, Variable 4 and change those last two letter to T2

So basically check if all four variables end in T1, if so pick a random variable and amend the text to end in T2 instead. Thank you!
B
9
S
2
Posts: 56
Reputation: 668

### » Mon Sep 07, 2015 4:02 pm

Would either of these two work?

If Variable 1 = ????"1"

If Variable 1 = "????1"
B
9
S
2
Posts: 56
Reputation: 668

### » Mon Sep 07, 2015 4:41 pm

If it's always 2 characters at the end then, if the text was in a variable called 'mytext', then you can get the last 2 characters using:

right(mytext,2)

If your vision so exceeds your ability, then look to something closer.
Moderator
B
142
S
32
G
89
Posts: 5,802
Reputation: 62,198

Thank you.
B
9
S
2
Posts: 56
Reputation: 668