on ‎2010 May 05 10:47 AM
Hi,
I am getting one string like 123/456, I need to split the string at '/' and pass 123 to one target and 456 to another. Is there any function to achieve this requirement please let me know...
Basha
Request clarification before answering.
It can be done easily with combination of standard functions like substring, indexOf, lastIndexOf and length.
For num1 , use substring(input,0 ,indexOf(input, "/") )
For num2 , use substring(input , IndexOf(input, "/") , length(input))
Or go for UDF. You need to create 2 udf as shown below.
public String getnum1(String input, Container container)
{
String arr[] = input.split("/");
return arr[0];
}
public String getnum2(String input, Container container)
{
String arr[] = input.split("/");
return arr[1];
}Regards,
Sunil Chandra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Basha,
U cannot achive this with just built in functions.. because the substring will have only 1 parameter which is the string...
Try this UDF,One is sufficient...
public String getParts(String input,int num, Container container)
{
String tempArr[] = input.split("\\|",-1); // that is \ \ | in quotes
return tempArr(num);
}
Now for getting first part call this UDF with input,0
for getting 2 nd part call with input,1
Babu
Edited by: hlbabu123 on May 5, 2010 4:04 PM
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.