Replace All for Double Quotes
Ok I am having some trouble "cleaning up" a text field for import into a DB.
The tex contains a bunch of double quoted (") and single quoted (') information. Thus when it iserts into a DB file it fails the import.
Any ideas on how I clean those upa nd replace them with "other characters".
For example would like to replace the " with a ^ and replace the ' with a ?
Thanks.
I usually use a function like
I usually use a function like this:
// Fix format issues.
String fixString(String value)
{
if (value != null)
{
value = value.replaceAll("\"", """);
value = value.replaceAll("&", "&");
value = value.replaceAll(" ", " ");
value = value.replaceAll("\\s{2,}", " ");
value = value.trim();
}
return ( (value==null || value.equals( " " ))? "" : value );
}
dataRecord.put("VALUE", fixString(dataRecord.get("VALUE")));
dataRecord.put("VALUE2", fixString(dataRecord.get("VALUE2")));
Thanks Jason. Worked like a
Thanks Jason.
Worked like a charm.