views:

43

answers:

2

I'm running a series of regex substitutions (i.e. String.replaceAll calls) to convert all the special characters in a text file to XML parseable special characters. For example:

string_out = string_out.replaceAll("&", "&");

I've hit a stumbling block replacing the 'section character' that is, this little squiggle: §

For starters, I'm doing my editing in vi, so I can't even paste the character in there, it being not a member of standard or extended ascii. I can't see specifying it by hex code in the regex working either, for the same reason.

How would you specify this character for a regex substitute? Or if you just want to drop in and tell me there's already a function tucked away somewhere to do the character conversion I'm doing by hand, that's cool, too.

A: 

cant you simply use the unicode codepoint?

ennuikiller
+3  A: 
Unicode: §
Hex:     0xA7
html:    §
name:    section sign

You can find it in the latin-1 supplement.

Andreas_D
This was similar to my line of thinking, but I had a bit of wrestling with the java to make it work. This turned out to be the line of code that did it: `string_out = string_out.replaceAll("\\xA7", "§");`Two catches here were that the backslash had to be doubled to make a valid escape code, and Java still didn't like it until the A was capitalized.
baudot