Quantcast
Channel: SCN : Blog List - Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 676

RegEx matching in graphical mappings

$
0
0

Regular expressions can be a very powerful tool. You can use them to validate email addresses, check whether a value starts with a capital, etc, etc.

 

You can implement a UDF in SAP PI that does regex matching for you:

 

udfProps.png

Pattern r = Pattern.compile(regex);

Matcher m = r.matcher(theText);

return ""+m.matches();

 

This UDF will return 'true' if a match is found between the text in the first argument and the regular expression in the second; otherwise it returns 'false'.

 

An example

The input message contains a list of values, and in your mapping you want to pick the one that is an email address.

 

  • A regular expression to check whether a string is an email address is
    ^[A-z0-9._%+-]+@[A-z0-9.-]+\.[A-z]{2,4}$

sample.png

 

For more information on the format of regular expressions, see http://www.vogella.com/articles/JavaRegularExpressions/article.html.


Viewing all articles
Browse latest Browse all 676

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>