on 07-11-2008 6:47 PM
Hi all,
Can anyone give me UDF code for trimming eaither side.........
thanks
hi sirijna,
if your requirement is like trimming left and right side of the field then.......you can go through the thread...........where gabriel gave the exact code for this type of requirement.........
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;
}
Thanks,
Madhu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
You dont require to write a UDF , its the same case use TRIM standard function in both scenarios (right trim and left trim)because it works perfect.
E.X:
" 1234" --> TRIM --> "1234"
"1234 " --> TRIM ---> "1234"
But still if you need to write the UDF then below is the code:
UDF
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;
}
Hope this helps
Thanks
Saiyog
Please update your thread if any issues or close the thread and reward points;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
We have trim function in the text function type , it removes left sede and right side white spacess.
If you want java code check the below link
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.
see my reply on the thread
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 | |
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.