regex results differences in same check

Hi I have a some that is running differently on two servers.

I am trying to replace the charater that represents a non-breaking

space with &160; the HTML equivalent.

The following code gives two diffrent results:

java.util.regex.Pattern pattern =

java.util.regex.Pattern.compile("\\u00C2\\u00A0");

if (pattern.matcher(str).find()) {

System.out.println("found a space");

} else { System.out.println("did not find a space");

}

pattern = java.util.regex.Pattern.compile("\\u00C2");

if (pattern.matcher(str).find()) {

System.out.println("found 302");

} else { System.out.println("did not find 302");

}

pattern = java.util.regex.Pattern.compile("\\u00A0");

if (pattern.matcher(str).find()) {

System.out.println("found 240");

} else { System.out.println("did not find 240");

}

On one server I get:

did not find a space

did not find 302

found 240

On the Other I get:

found a space

found 302

found 240

Both servers are running redhat 8.0 and have the same jdk.

Does anyone know what setting on the system could cause this?

thanks.

[1266 byte] By [Isaacdov3] at [2007-9-30 6:31:03]
# 1
You can use this instead of thatPattern p = Pattern.compile("a*b");Matcher m = p.matcher("aaaaab");boolean b = m.matches();
ShivaKatula at 2007-7-1 21:06:33 > top of Java-index,Administration Tools,Sun Connection...
# 2

I found a workaround.

1. convert to Western European

try {

byte[] encVal = str.getBytes();

str = new String(encVal,"ISO-8859-1");

} catch (Exception e) {}

2. do 2 search and replaces

str = str.replaceAll("\\u00C2\\u00A0"," ");

str = str.replaceAll("\\u00C3\\u0082",""); // Â For some reason one the systems that was working under UTF-8 needs this replace. In the system where this was not working, this multibyte char does not show up.

This works fine for now, but I would like to know why the same String is different on the two servers.

Isaacdov3 at 2007-7-1 21:06:33 > top of Java-index,Administration Tools,Sun Connection...