Pattern p = Pattern.compile("[/\\\\]([a-zA-Z0-9_]+\\.ncx)$");
Matcher m = p.matcher("\\sample.ncx");
if (m.find())
{
System.out.printf("The filename is '%s'%n", m.group(1));
}
output:
The filename is 'sample.ncx'
$ anchors match to the end of the line (or to the end of the line in multi-line mode). It is at the end of your regular expression, not at the beginning.
[/\\\\] , . , , . .
[a-zA-Z0-9_]+ ; plus, .
, , dot --and , Java.
alternation (|) , . , , .