I need to write a regular expression that finds javascript files that match
<anypath><slash>js<slash><anything>.js
For example, it should work for both :
- c:\mysite\js\common.js (Windows)
- /var/www/mysite/js/common.js (UNIX)
The problem is that the file separator in Windows is not being properly escaped :
pattern = Pattern.compile(
"^(.+?)" +
File.separator +
"js" +
File.separator +
"(.+?).js$" );
Throwing
java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence
Is there any way to use a common regular expression that works in both Windows and UNIX systems ?