on 10-12-2010 2:53 PM
All,
I'm receiving a string ##FName#LName## ,I need to send FName to one field and LName to another fileds.
Please provide me with some inputs.
Thanks,
Hi Pushpa.
Use one UDF and two parameters one for string and the other the position,
value : String (e.g ##FName#LName)
pos : Position that you want.
String result = "";
String array01[] = value.split("##");
String array02[] = array01[1].split("#");
result = array02[pos];
return result;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
You can use REGEX in the UDF to achieve this
Include 2 parameters in the UDF Say
a - [input (##Ram#Kumar##) ]
b - [Index values for first name (2) and last name (4)]
Imports: java.util.regex.*;
Parameters:
a, b
int indexVal = Integer.parseInt(b);
String pattern = "(##)(.*)(#)(.*)(##)"; // first (.*) is first name - index val is 2 and last name index value is 4
Pattern d = Pattern.compile(pattern);
Matcher m = d.matcher(a);
if(m.find())
{
a = m.group(indexVal);
}
return a;
Use the same code for different fields by changing the constant(index values) in the mapping.
you can refer the below forum discussion further as srini suggest...
Regards
Ramg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use 2 seperate UDF to extract the 2 fields. for the leading ##, you use substring and ignore the first two values(##) and then split by #.
please use the UDF mentioned below.
use this UDF
for first name
public String StringSplit(String var1, Container container) throws StreamTransformationException{
int len = var1.length();
var1= var1.substring(2,len);
String arr[] = var1.split("#");
return arr[0];
for last name
public String StringSplit(String var1, Container container) throws StreamTransformationException{
int len = var1.length();
var1= var1.substring(2,len);
String arr[] = var1.split("#");
return arr[1];
Regards,
Srinivas
Edited by: Srinivas on Oct 12, 2010 10:59 PM
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.