Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get prefix string value in Android? [closed]

i am working in Android application, Using hasPrefix to get a first string value in iphone, but i didn't know how to do this? please help me

In iphone:

Name =@"Thomas edward";
if ([result hasPrefix:Thomas])  
{

}

Similarly Android, how to do this?

Thanks in advance

like image 663
SampathKumar Avatar asked Aug 16 '12 13:08

SampathKumar


People also ask

How do you find the prefix of a string?

A prefix of a string S is any leading contiguous part of S. A suffix of the string S is any trailing contiguous part of S. For example, "c" and "cod" are prefixes, and "ty" and "ity" are suffixes of the string "codility".

How do I find the prefix and suffix of a string?

A prefix of a string S is a substring of S that occurs at the beginning of S. A suffix of a string S is a substring that occurs at the end of S. Output the size of the largest such subset. Note that the chosen subset can have a single string also.

How do you prefix a string in C++?

C++ std::string Checking if a string is a prefix of anotherstd::string prefix = "foo"; std::string string = "foobar"; bool isPrefix = std::mismatch(prefix. begin(), prefix. end(), string. begin(), string.

What do you mean by prefix of a string?

A prefix of a string is a substring of that occurs at the beginning of ; likewise, a suffix of a string is a substring that occurs at the end of .


1 Answers

You can use startsWith, or check the index of the string

if(result.startsWith("Thomas")) 
{

}
like image 140
CBredlow Avatar answered Oct 18 '22 09:10

CBredlow