tags:

views:

73

answers:

1

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.

+7  A: 

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.

willcodejavaforfood
I see, will read up. Thanks!
@willcodejavaforfood: Congrats for achieving 5 digits ;)
Adeel Ansari
@Adeel Ansari - Thanks mate :)
willcodejavaforfood