Skip to Content
In this short blog, I’d like to introduce you how to, in simple way, extend the abilities of your mapping programs. You can achieve it using regular expressions so loved by Perl programmers. What should you use it for? In order to have more comprehensive mapping with less blocs in graphical mapping. If you wonder what are these regular expressions, please check these links:  – wikipedia link– blog about java library (by Morten Wittrock) An introduction to regular expressions in Java  – java documentation, here you can find a pattern syntax link I’ve prepared 4 very simple UDFs (user defined functions) which might be used in your own scenarios. Thanks to them, you can utilize the power of regular expressions. First one is to check if the input string is compatible with regular expression. Second is checking if regular expression exists in input string. Third one is the extraction of first substring compliant with regular. And the last one is replacing first regular expression with another string. All of these functions are value functions. image 1) checking if string fulfill regular expression pattern  You can use it when you would like to either check if data is correct or use output from this in “if” statements.     import: java.util.regex.*;arguments: a,bcode:return “”+Pattern.matches(b, a);  Below are two examples when input fulfil and when it doesn’t. imageimage 2) checking if any subset of the input string fulfill regular expression pattern  import: java.util.regex.*; arguments: a,bcode:Pattern pat=Pattern.compile(b); Matcher m=pat.matcher(a); return “”+m.find(); image 3) returning of substring which fulfill regular expression pattern  import: java.util.regex.*; arguments: a,b code:  Pattern pat=Pattern.compile(b); Matcher m=pat.matcher(a); if(m.find())      return m.group(); else      return ResultList.SUPPRESS; image 4) replacing all substrings which fulfill regular expression pattern  import: java.util.regex.*;arguments: a,b,ccode:Pattern pat=Pattern.compile(b); Matcher m=pat.matcher(a); return m.replaceAll(c); image 5) sample compilation of few functions  In this example I’d like to show how you can use regular expression to extract value from one element in xml. It can be especially useful for people who don’t know how to use DOM or SAX. For instance you can use it after RFC lookup function (link to RFC lookup).   For example as a result of RFC lookup you are getting such XML structure: Content i1Content i2 You would like to extract value of i1 and you can do it using regular expressions UDF functions. image
To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply