on 02-24-2014 1:45 PM
Hello Experts,
i have the below requirements in Mapping
From the input string it have to find first "7", then it have to send next 9 digits from there on to the target field.
For eg1: if input is "-QET7123456789" output should be "7123456789".
eg2: if input is "~79992573651234" output should be "7999257365"
Regards,
Ruban.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ruban - use the below java code
return var1.substring(var1.indexOf("7"),var1.indexOf("7")+9);
where var1 is your input string.
if you don't have 9 char after the index of 7 then you might have to use below UDF
if (var1.length()>(var1.indexOf("7")+9))
return var1.substring(var1.indexOf("7"),var1.indexOf("7")+9);
else
return var1.substring(var1.indexOf("7")); // change it as per your needs..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The only thing I would change is the index on the end digit as Hareesh has suggested because of how substring works in Java. Returns a new string that is a substring of this string. The substring begins at the specified beginIndex
and extends to the character at index endIndex - 1
. Thus the length of the substring is endIndex-beginIndex
.
Since this is the case I would change it to the following:
return var1.substring(var1.indexOf("7"),var1.indexOf("7")+10);
Regards,
Ryan Crosby
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.