简体   繁体   中英

It return false instead of true

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

newfilename = Pattern.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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM