on 05-05-2010 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
Hi,
Try this udf it works for your requirement..
String nm = "000012304/abc";
String search = "/";
String result = "";
String res = "";
int i;
i=nm.indexOf(search);
result = nm.substring(0,i);
res = nm.substring(i+1);
here nm is the input number you will be getting, search where "/" occurs and using substring read the first half and second half
regards,
Kishore
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Hi,
Use String.Split method it will work for you.
google it for sample codes,and make it as UDF as per your requirement.,
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use the substring function to get the before and after values.
Regards,
Abhishek.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This is not possible without using a UDF. You must create a context type UDF with a .split on it.
Hope this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
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.