I am trying to compile following regex
/^[~`!@#$%^&*()_+=[]{}|;':",./<>?a-zA-Z0-9-\w\s]+$/
String fileNameRegex = '/^\[~`!@#$%^&*()_+=\[\]\{}|;':",.\/<>?a-zA-Z0-9-\w\s\]+$/';
Pattern FileNamePattern = Pattern.compile(fileNameRegex);
String testString = '世界tes';
Matcher FileNameMatcher = FileNamePattern.matcher(testString);
if(FileNameMatcher.matches())
{
system.debug('***true**');
}
else{
system.debug('***false**');
}
I did escape special charters with '\' , please advise.
\/\^\[~`\!@\#\$%\^&\*\(\)_\+\=\[\\\]\\\{\}\|;'\:",\.\\\/\<\>\?a\-zA\-Z0\-9\-\\w\\s\]\+\$\/