Java Regex to find a exact match for a word

前端 未结 1 678
不知归路
不知归路 2021-01-21 18:26

I am trying to build a regex pattern in Java to find a exact match of a word.

For example, the word hot should be found in the first 3 strings but not in th

相关标签:
1条回答
  • 2021-01-21 19:04

    You can use word boundaries \b around your pattern. A word boundary does not consume any characters. It asserts that on one side there is a word character, and on the other side there is not.

    \bhot\b
    
    0 讨论(0)
提交回复
热议问题