I need to test string weather it matches a specific pattern.
String is the full file path, for example: 
C:\some\path\to\folder\folder.jpg
or
C:\another\file\path\file.jpg
Pattern is: file name without extension should match exact parent folder name, where it is located. File name could be any possible value.
So, in my example only first string matches pattern:
C:\some\path\to\folder\folder.jpg
Can this test be made in javascript using one regular expression?

folder.jpgdoes have an extention of.jpg. How is condition file name without extension should match exact parent folder name, where it is located satisfied here ?