Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check If String Contains any Of the Word From Given List?

Status
Not open for further replies.

shivam bhatele

Programmer
Apr 30, 2020
4
0
0
IN
Hello All, I am facing some error while working on below program. Check if the string contains any of the words from the given list of string. Here's what I've done so far:
I used interviewbit java compiler to ruh this program.

Java:
private void text_type(){
 String input_data = kw_url_holder.getText().toString();
    String[] words = {"google", "bing"};
 if(URLUtil.isValidUrl(input_data) & input_data.contains("google")){
     Toast.makeText(YTTags.this, "It's URL",Toast.LENGTH_LONG).show();
 }
 else{
     Toast.makeText(YTTags.this, "It's Word",Toast.LENGTH_LONG).show();
 }
}

This code checks if String is Word or URL. In the URL, I want to check if the URL contains list of words. I've used mydata.contains() but it only checks one single word. Can anyone suggest me?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top