cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping

rubanprasanth_s
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

HI,

Pls try this, will be helpful

former_member184720
Active Contributor
0 Kudos

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..

Ryan-Crosby
Active Contributor
0 Kudos

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