Monday, September 17, 2018

Specify Criteria or Results in Saved Searches Using Regular Expressions

Regular expressions are a powerful tool for finding specific patterns within a string. They can be used both on the Criteria tab to allow searching for records based on substring values as well as on the Results tab to format and display data based on substrings.
 
One of the available regular expressions functions is regexp_substr().
 
Here is an example that can be used on a transaction search to display the first hyperlink in the body memo field which is separated by spaces to be displayed as a link. In the Results tab > Columns subtab, add Formula (Text) and use the formula below:

DECODE(REGEXP_SUBSTR({memomain}, '(http\S+)'),'', '', '<a href="' || REGEXP_SUBSTR({memomain}, '(http\S+)') || '">Click Here</a>')

If the body memo field contains this string for example:
            "Here is a link to the customer contract: https://system.netsuite.com/core/media/media.nl?id=1544998&c=123456&h=b8396676d7d55784b5b1&id=1744991&_xt=.pdf&_xd=T"

The function will display the following in the search results:
    Click Here

Here are some links to Oracle documentation about the supported regular expressions: 
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions131.htm#SQLRF06303
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/ap_posix001.htm
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_regexp.htm#g692318

No comments:

Post a Comment