Escaping quotes to the nth degree
I'm having big troubles with escaping quotes.
Here's what I'm trying to do:
In my Java properties file, there may be a value that contains a URL with quotes. In this case it's a JavaScript function that opens a URL in a new window. Within those quotes, the actual URL should be inserted, for instance:
# Open the story in a new window
link.story = javascript:open_window('{0}', '{1}', 546, 400, false);
Now, I tried MessageFormat.format, and it works, *but* it also deletes my quotes, leaving me with something like
javascript:open_window(http://java.sun.com, myNewWindow, 546, 400, false);
I then tried escaping all quotes with String.replaceAll, however nothing I do works. If I use
string.replaceAll("\'", "\\\\'");
it escapes quotes (I'm trying just about every number of backslashes, too!), resulting in
javascript:open_window(\'{0}\', \'{1}\', 546, 400, false);
However, after MessageFormat.format, I get
javascript:open_window({0}, {1}, 546, 400, false);
So, the big question is: What exactly do I need to be able to write quotes "naturally" in the properties file and then get what I need, namely
javascript:open_window('http://java.sun.com', 'myNewWindow', 546, 400, false);
Any help would be greatly appreciated!
Regards,
Eric

