Regular expression not matching subwords in phrase

后端 未结 1 1715
囚心锁ツ
囚心锁ツ 2021-01-24 03:34

My program displays the matching results, but I want to sort the results as best match, second best match ans so on.

My text file contains the following line:

相关标签:
1条回答
  • 2021-01-24 03:54

    You have mixed pattern and search space. The line (strLine) is your search space and key is the pattern. Fix:

    Pattern p = Pattern.compile(key);
    Matcher m = p.matcher(strLine);
    
    0 讨论(0)
提交回复
热议问题