on 03-06-2015 2:08 PM
Hi Experts,
i need a UDF for splitting of a string based on the delimiter "." i have done with the following udf but it is not working with my delimiter. it is working with the ";" delimiter.
for (int i = 0; i < field1.length; i++)
{
String tokens[] = field1[i].split(".");
field1_out.addValue(tokens[0]);
field2_out.addValue(tokens[1]);
field3_out.addValue(tokens[2]);
sample input --Action.20150302.0101 so here i need to split it in to 3 strings so that i will do some validations on the timestamp.
please help me guys
Thanks
Giridhar
Hi Giridhar,
Hareesh already given the answer, he is right but you can use below code instead of hard coding the string array values in your code.
public void split(String[] input, ResultList result, Container container) throws StreamTransformationException {
String[] StrArray = input[0].split("\\.");
int len1 = StrArray.length;
for (int i = 0; i < len1; i++) {
result.addValue(StrArray[i]);
}
}
Regards,
Praveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
change it to String tokens[] = field1[i].split("\\."); and try?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.