0
Input a sentence and search for a word..
Use Java for the program....and use string func...
3 Réponses
+ 4
in java..
String a = "some text";
if(a.contains("some"))
System.out.println("found");
//Outputs "found"
+ 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)); }
+ 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"