0

Input a sentence and search for a word..

Use Java for the program....and use string func...

16th Dec 2017, 5:43 AM
David Anderson
3 Réponses
+ 4
in java.. String a = "some text"; if(a.contains("some")) System.out.println("found"); //Outputs "found"
16th Dec 2017, 5:58 AM
Md. Nafis Ul Haque Shifat
Md. Nafis Ul Haque Shifat - avatar
+ 5
String string = " Hi David here is one method by which you can search word in string "; String keyword = "search"; Boolean found = Arrays.asList(string.split(" ")).contains(keyword); if(found){ System.out.println("Keyword matched the string"); } may this can help you or String text = "I m a beginner "; List<String> tokens = new ArrayList<String>(); tokens.add("beginner"); tokens.add("I"); String patternString = "\\b(" + StringUtils.join(tokens, "|") + ")\\b"; Pattern pattern = Pattern.compile(patternString); Matcher matcher = pattern.matcher(text); while (matcher.find()) { System.out.println(matcher.group(1)); }
16th Dec 2017, 6:01 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
If you are using c# then you can use the Contain function Just like string a = "some text"; if(a.Contains("some")) Console.WriteLine("found"); //Outputs "found"
16th Dec 2017, 5:51 AM
Abdullah Atique