开发者

It return false instead of true

开发者 https://www.devze.com 2023-01-22 04:31 出处:网络
How to match \"FileNew\" in \"FileNewABC\" which is a value from f_var and return true? newfilename = Patte开发者_运维百科rn.compile(\"FileNew\").matcher(f_var).matches();

How to match "FileNew" in "FileNewABC" which is a value from f_var and return true?

newfilename = Patte开发者_运维百科rn.compile("FileNew").matcher(f_var).matches();

It always return false.


You need to use find or it will try and match entire input to the pattern.

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

  • The lookingAt method attempts to match the input sequence, starting at the beginning, against the pattern.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消