views:

60

answers:

2

I am generating a Word doc in xml based on customer input, and of course it blows up whenever an & is used. I tried replacing all instances of & with &, but then & literally shows up in my Word Doc. Here's my code:

        static String replace(String in) {
            String ampersand = "&(?![a-zA-Z][a-zA-Z][a-zA-Z]?[a-zA-Z]?;)";
            return in.replaceAll(ampersand,"&");
        }

Any ideas?

A: 

Have you tried replacing the ampersand with & or & (unicode)?

The Elite Gentleman
I just tried both of those, but neither one worked for me.
John
A: 

Word 2007 itself does &, so your problem must be something else.

plutext