Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a range of string in Android? [closed]

Tags:

android

range

Currently i am working in simple android app, I have tried to range of string in iphone, its works, but i didn't know this in Android app? In iphone:

result = "mobile - check balance | rate: 0.036"

if ( [result rangeOfString:@"rate:"].location != NSNotFound) 
{

}

How to convert this in Android, please help me

like image 569
SampathKumar Avatar asked Aug 16 '12 12:08

SampathKumar


2 Answers

Have you tried something like result = "mobile- check balance | rate: 0.036"

if( result.indexOf("rate")!=-1)
{}

I've been using objective-c recently too, and I pulled this from here

like image 117
CBredlow Avatar answered Oct 26 '22 07:10

CBredlow


try this

    String strVowels = "mobile - check balance | rate: 0.036";
    if (strVowels.contains("rate:") == true) {
        // String contains IOU sub-string!
        Log.i("mylog", "this word is in string.");
    } else {
        Log.i("mylog", "this word is not in string.");
    }
like image 24
Max M. Avatar answered Oct 26 '22 07:10

Max M.