Substituting a Regular Expression for a Recordset Field

Use the Substitution dialog box to configure advanced read and write options for both attributes and recordset fields.


Use regular expressions judiciously and only when necessary. Added performance overhead can occur when using regular expressions.

In this example, use the sample model CCSDemo to substitute a recordset field usually displayed with a trailing minus sign, with one which will be displayed with a leading minus sign. There are also steps to test the output.

  1. Open CCSDemo in the Design Tool.

  2. Click to connect to the host.

  3. Select AcctTransactions from the Entity list to navigate to the AcctTransactions entity.

  4. Click the Recordset tab, then select the Fields tab on the lower portion of the Recordset tab.

  5. Select the row named Amount.

  6. In the Read group box, click Advanced to open the Read Field Substitutions dialog box.

  7. Click Insert - - to add a row for a new substitution.

  8. Create an expression that matches a money field with a trailing minus sign. In the Search For column of the newly created row, enter the expression:
    (^|[^-.\d])(\d+(?:\.\d+)?)-(?=[^-.\d]|$)

    See this expression in detail

  9. To transpose the minus sign to the front of the field, enter the following in the Replace With column:
    $1-$2

  10. In the Description column, type:
    Move minus sign to front

  11. Close the Read Field Substitutions dialog box and click Apply to update your model.

  12. To test the results, select Procedure Test from the Debug menu.

  13. From the Table drop down list, select Transactions and confirm that the GetTransactions procedure is selected.

  14. In the Value field of the Procedure Filters box, type 167439459

  15. Click Execute.

  16. Scroll down the procedure output and note that several amounts have a leading minus sign.

 

Related Topics
Bullet How to use Regular Expressions