Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

search string inside a word in java

I want to search a word inside a string : For example let the String be "ThisIsFile.java" and let i want to search "File.java" or "IsFile"

This is something like sql 'like' query but unfortunately i am not getting that string from database.

Please suggest me any good solution for this. Thanks

like image 939
Mohammad Adil Avatar asked Jan 30 '26 23:01

Mohammad Adil


1 Answers

There's a variety of ways of achieving this and the method you choose will depend on the complexity of your queries. For a simple plain symbol/word match the String class provides a contains method that takes a single parameter, the String to search for - and returns true if it occurs within the search String.

bool containsFile = myString.contains("file");
like image 193
mmccomb Avatar answered Feb 01 '26 14:02

mmccomb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!