I wanted to make a validator for amazon following these specification http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-keys.
And I created my pattern as:
private static Pattern objectKeyNamePtrn = Pattern.compile("^[a-z0-9_-!.*'()]{6,30}$");
But, I am getting error:
Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: java.util.regex.PatternSyntaxException: Illegal character range near index 11 ^[a-z0-9_-!.*'()]{6,30}$
I tried escaping with '\' but didn't work.
And also Amazon guys says, The name for a key is a sequence of Unicode characters whose UTF-8 encoding is at most 1024 bytes long.
How should I check that, using regular expression?