-3

I am trying to filter the whole word from the sentence.

like example

Text : This is a question about programming language.

Search Text is : about pro

Result should be : about programming

Basically i want to get the whole words from the sentence.

I referred this How to find a whole word in a String in java also. but it searching for matching words and not characters

I would really appreciate your help

Thanks

Community
  • 1
  • 1
Fahim
  • 12,198
  • 5
  • 39
  • 57

1 Answers1

3

Do it with regex: Something like

about pro.*?\b

Will match about pro and then some characters and then a word boundary (a whitespace or punctuation mark). This way you don't have to make multiple substrings (which is a costly operation).

Astrogat
  • 1,617
  • 12
  • 24