on 04-23-2013 11:07 AM
Hi,
Hopefully an easy answer to this one!
How do you strip out carriage return characters from a field on the outbound payload during mapping? I am assuming you use the replaceString function but what value would you use to represent the Carriage Return in the first of the two Constants needed in a replaceString?
Cheers,
PaulC.
>but what value would you use to represent the Carriage Return in the first of the two Constants needed in a replaceString?
First constant uses "\n" or "\r" or both "\n\r" (Depends on what you get in the payload)
Second constant uses " " (empty string)
otherwise write a simple udf
String s1 = "this\r\nis a test";
String s2 = s1.replaceAll("[\n\r]", "");
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Paul,
According to ASCII table carriage return has decimal value 13. You can use below UDF to remove any character based on its ASCII value.
Here ascii variable is used to hold ASCII value of the character to be removed.
public static String removeCR(String s)
{
int i,l,ascii=13;
String a="";
if(s!=null && !s.equals(""))
{
for(i=0,l=s.length();i<l;++i)
{
if((int)s.charAt(i)!=ascii)
{
a=a+s.charAt(i);
}
}
s=a;
}
return s;
}
Regards
Anupam
Message was edited by: Anupam Ghosh
Apologies, but due this topic being approved for moderation hours after I posted it the topic has never appeared on the first page i.e. nobody has probably seen it!!
MEMO to mods: Stick approved topics at the top of page 1 to give them a chance !!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.