The pattern in the error message is not the same as the pattern in the properties file. That's a clue. I believe a backslash is a special character in properties files in the same way that it is in string literals. So the pattern is interpreted as shown in the error message, and the ? is therefore in an invalid position.
Try using a double backslash instead, which will be unescaped to a single backslash and should do what you want.
A Kumar wrote:my properties file has
Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 10
Whats wrong with the pattern
Basically, the '?' doesn't have anything to work with.
'?' means "0 or 1", so it needs a subpattern to work with. The previous character to it is a '|' though, which is ALSO a metacharacter, so the pattern compiler is telling you that it doesn't have anything to evaluate.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop