Android Question Compare strings

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

I can't seem to work this simple thing out and hoping someone can help me out with it..

Lets say I have 2 strings:
String 1 = "Testing"
String 2 = "ting"

I want to know if string 2 is part of string 1, which in the above example it is as it ends in 'ting'. (or another example if string 2 = "estin" then it should also return true as it's in string 1)

If string 2 is not part of string 1 (for example string 2 = "bob" or if string 2 = "Teing") then it should return false.

However, the string length and the actual string maybe different.

Anyone able to help me out with this ?
 

LucaMs

Expert
Licensed User
Longtime User
Hello,

I can't seem to work this simple thing out and hoping someone can help me out with it..

Lets say I have 2 strings:
String 1 = "Testing"
String 2 = "ting"

I want to know if string 2 is part of string 1, which in the above example it is as it ends in 'ting'. (or another example if string 2 = "estin" then it should also return true as it's in string 1)

If string 2 is not part of string 1 (for example string 2 = "bob" or if string 2 = "Teing") then it should return false.

However, the string length and the actual string maybe different.

Anyone able to help me out with this ?


If String1.Contains(String2) Then...
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Thanks to both of you.. Told you it was something simple.. (must be one of those days)
 
Upvote 0
Top