Checking a variable for a substring
Posted: Fri Jun 17, 2016 12:50 pm
Hi!
So lets say I have a variable named sunSet which holds the string "overTheHills"
and I want to check the last 5 positions of the string sunSet to see if it holds the word "Hills"
If it does, I want to execute a set of functions, and if it doesn't, I want to do something else..
Is it possible to only check the last specified positions? like starting from the end of the string?
For example if I searched the String "OverHillsThe", I don't want the check to go through..
I want it to be true only if Hills is at the end of the string.
So the "contains" function wouldn't work..
So lets say I have a variable named sunSet which holds the string "overTheHills"
and I want to check the last 5 positions of the string sunSet to see if it holds the word "Hills"
If it does, I want to execute a set of functions, and if it doesn't, I want to do something else..
Is it possible to only check the last specified positions? like starting from the end of the string?
For example if I searched the String "OverHillsThe", I don't want the check to go through..
I want it to be true only if Hills is at the end of the string.
So the "contains" function wouldn't work..