on 12-13-2011 1:15 PM
Hi All,
Can anybody provide me an UDF to remove the special character i.e., ' from a string. Your help is highly appreciated.
Ex: Source field contains the values as ABC'S then in target field value as ABCS.
Regards
Faisal
Hi,
Try using standard text function replaceString()
Input ------->
Constant(')--> replaceString() ----->target
Constant()--->
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If your requirement is just to remove single special character like ( ' ) then you can use Standard function replaceString itself. You basically need to provide three inputs to the function. one from the source, second delimiter in this case ' using constant and another constant with empty space. Already Anupam explained it. If you have multiple delimiter pattern and unpredictable data that comes from the source then better go for the UDF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
UDF is not required for this.
You can use standard text function replaceString to achieve your requirement.
Regards
Ramesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
by writting small UDF you can remove special character.
public static String removeSpecialChar(String s)
{
try
{
int i,j;
String a="";
String stringSet[]={"ABC'S"};
for(i=0;i<stringSet.length;++i)
{
j=s.indexOf(stringSet<i>);
while(j>=0)
{
a=s.substring(0,j);
a=s.substring(stringSet<i>.length()j);
s=a;
j=s.indexOf(stringSet<i>);
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
return s;
}
regards,
ganesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please try with below logic...
UDF:
String result = "";
String[] splt;
delimiter = "'"; //special character to be removed
splt = input.split(delimiter);
for(int i =0; i < splt.length ; i++)
result = result + splt(i);
Regards,
Priyanka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.