DockYard
DockYard

Reputation: 1040

Java regex not matching the string "abc.txt" with pattern "abc"

I am trying to match a string using java regex.

My string is "abc.txt" which is a file name. The regex I am using is "abc".

String fileName = "abc.txt";
Pattern pattern = Pattern.compile("abc");
Matcher matcher = pattern.matcher(fileName);
System.out.println(matcher.matches());

But some how it does not match. Infact using notepad++ regex search, it matches completely fine.

Please help

Upvotes: 1

Views: 35

Answers (0)

Related Questions