It returns false instead of true

How to map "FileNew" to "FileNewABC", which is the value from f_var and returns true?

newfilename = Pattern.compile("FileNew").matcher(f_var).matches(); 

It always returns false.

+4
source share
1 answer

You need to use find or try to match all input with a pattern.

  • The match method attempts to match the entire input sequence with the pattern.

  • The lookAt method tries to match the input sequence, starting from the beginning, with the template.

  • The search method scans the input sequence, looking for the next subsequence that matches the pattern.

+7
source

All Articles