How to match "FileNew" in "FileNewABC" which is a value from f_var and return true?
如何匹配“FileNewABC”中的“FileNew”,它是来自f_var的值并返回true?
newfilename = Pattern.compile("FileNew").matcher(f_var).matches();
It always return false.
它总是返回错误。
1 个解决方案
#1
7
You need to use find
or it will try and match entire input to the pattern.
您需要使用find或它将尝试匹配模式的整个输入。
-
The matches method attempts to match the entire input sequence against the pattern.
matches方法尝试将整个输入序列与模式匹配。
-
The lookingAt method attempts to match the input sequence, starting at the beginning, against the pattern.
lookingAt方法尝试将输入序列(从头开始)与模式匹配。
-
The find method scans the input sequence looking for the next subsequence that matches the pattern.
find方法扫描输入序列,寻找与模式匹配的下一个子序列。
#1
7
You need to use find
or it will try and match entire input to the pattern.
您需要使用find或它将尝试匹配模式的整个输入。
-
The matches method attempts to match the entire input sequence against the pattern.
matches方法尝试将整个输入序列与模式匹配。
-
The lookingAt method attempts to match the input sequence, starting at the beginning, against the pattern.
lookingAt方法尝试将输入序列(从头开始)与模式匹配。
-
The find method scans the input sequence looking for the next subsequence that matches the pattern.
find方法扫描输入序列,寻找与模式匹配的下一个子序列。