JosephRussell Posted May 30, 2018 Posted May 30, 2018 Hi everyone, I've got two strings, eg. "Apple 1" and "Apple 2" and I want to compare the first 5 characters only, so I can test for the word "Apple" and have it return true for both strings. Any ideas if/how that can be done? Any help would be greatly appreciated! :)
Ghaunadaur Posted May 30, 2018 Posted May 30, 2018 (edited) If you don't mind using SKSE, you could do something like this bool Function FunctionX(string String1, string String2) int i = 0 bool j While i < 5 if StringUtil.GetNthChar(String1, i) == StringUtil.GetNthChar(String2, i) j = true else j = false return j endif i += 1 EndWhile return j EndFunction edit...or better use SubStringbool Function FunctionX(string String1, string String2) if StringUtil.SubString(String1, 0, 5) == StringUtil.SubString(String2, 0, 5) return true else return false endif EndFunction Edited May 30, 2018 by Ghaunadaur
JosephRussell Posted May 30, 2018 Author Posted May 30, 2018 Substring is just what I need! That's marvellous, thank you :D
Recommended Posts