Skip to Content

UDF to pick only numeric part in input value in SAP PI

Hi Experts,

Mapping requirement is to pick the numeric part from input & populate it in the target field.

Say if in input we get value like 'Box 23' then output value should be '23'.

Eg:

Box 23 [Input] - 23 [Output]

Postfach 1261 [Input] - 1261 [Output]

Thanks,

Ramu.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Nov 29, 2017 at 10:05 AM

    Hi Ramu,

    try this in your UDF:

    return var1.matches(“.*[0-9]{10}.*”);


    or use this blog

    The power of regular expressions in graphical mapping (XI)


    Regards,

    Alex

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 29, 2017 at 07:04 PM

    Hi Ramu,

    You can use regex and delete non-digits.

    str = str.replaceAll("\\D+","");
    Add comment
    10|10000 characters needed characters exceeded