Tuesday, June 9, 2015

Tools to develop regular expressions

Many times one being an ABAP developer needs to process strings. There are few options (like comparison operators, predicate functions and regular expressions) how to do that as I wrote about them here. The latter one is the most interesting. By using the regular expressions we can match whole character string or substring in order to evaluate what we need. By definition regular expressions are sequences of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. "find and replace" type of operations. They are provided by many programming languages - ABAP including. In the release 7.0 of NetWeaver regular expressions can be used as arguments of FIND and REPLACE ABAP statements. Also there are ABAP classes (CL_ABAP_REGEX and CL_ABAP_MATCHER) available where they can be used.

The most important part is to design the regex. To support the design time of the regex SAP is using the tools where the developer can "tune" particular regex. Within the tools one can design new regex directly running it on some sample data without writing ABAP test program. There are following tools available as ABAP reports:


DEMO_REGEX - provides ABAP statement FIND's interface to the regex.



DEMO_REGEX_TOY - on a top of ABAP statement FIND's interface to the regex there is also REPLACE statement supported.



No comments: