on 05-20-2008 5:36 PM
Hey,
I need to do some Left trim and right trim functions. Can anybody share theire experiences with these functions.
If possible provide me the UDF for both.
-S
1) left justify
function myudf(String a, Container container)
{
String r="", s="";
for(int i=0;i<a.length();i++)
{
if (a.charAt(i) == ' ' )
r=s+a.charAt(i);
}
return r;
}
2) right justify
function myudf(String a, Container container)
{
String r="";
for(int i=0;i<a.length();i++)
{
if (a.charAt(i) != ' ')
r=r+a.charAt(i);
}
return r;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sorry for the wrong code
function leftjustify(String a, Container container)
{
String r="";
for(int i=0;i < a.length();i++)
{
if (a.charAt(i) != ' ' )
{
r = r + a.substring(i);
break;
}
}
return r;
}
function rightjustify(String a, Container container)
{
String r="";
for(int i=0;i<a.length();i++)
{
if (a.charAt(i) == ' ')
{
r=a.substring(0,i);
break;
}
}
return r;
}
Hi,
In the standard functions, select TEXT --> trim function, then it will removes white space from the left and right sides.
If you want to write UDF then.
Create UDF(select cache type as Value) and give any argument name.(suppose str).
code
String trimmedStr = str.trim();
return trimmedStr;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can directly use Trim() functions during graphical mapping.
Its under text functions.
Gaurav Jain
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is no left trim and right trim function in JAVA
trim() function will alone trim all left and right whitespaces..
String str = " dsfdsf ";
String trimmedStr = str.trim();
System.out.println(str);
str=>dsfdsf with no space on left / right.
Here is your UDF
a->myudf->targetfield
function myudf (String a, Container container)
{
a=a.trim();
return a;
}
Apart from that in Graphical mapping contains trim() which can be directly used.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1) left justify
function myudf(String a, Container container)
{
String r="";
for(int i=0;i<a.length();i++)
{
if (a.charAt(i) = ' ' )
r=a.charAt(i);
}
return r;
}
2) right justify
function myudf(String a, Container container)
{
String r="";
for(int i=0;i<a.length();i++)
{
if (a.charAt(i)!=' ')
r=r+a.charAt(i);
}
return r;
}
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.