Hi folks,
I seem to be running into a little bit of trouble with the String.replaceAll() method.
I have a piece of code that does the following:
System.out.println(outerLine.replaceAll("{procName}", procName));
outerLine is a String object that is the result of a
BufferedReader.readLine() method. The code compiles okay, but when I execute the program, however, I run into an illegal repetition exception. This is the explicit error message:
Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repetition
{user}
at java.util.regex.Pattern.error(Pattern.java:1472)
at java.util.regex.Pattern.closure(Pattern.java:2473)
at java.util.regex.Pattern.sequence(Pattern.java:1597)
at java.util.regex.Pattern.expr(Pattern.java:1489)
at java.util.regex.Pattern.compile(Pattern.java:1257)
at java.util.regex.Pattern.<init>(Pattern.java:1013)
at java.util.regex.Pattern.compile(Pattern.java:760)
at java.lang.String.replaceAll(String.java:1706)
at TestObject.<init>(TestObject.java:36)
at TestObject.main(TestObject.java:57)
The line that is being processed at this point is:
User {user} will the required to provide more details. {user}, please ...
I would be grateful for any input into why the error occurs.
Thanks in advance.