Match Regex is one of the functions used to check the pattern of the particular data attribute. Mainly this is used to validate the Email address and Phone numbers. The following is the analysis which describes how to validate a phone number Using Match Regex function in SAP Information Steward Tool
Step 1: Create a Rule named PHONE_NUMBER_VALIDATION with a input Parameter called $Phone_number with the datatype of Varchar
Step 2: Go to the Script Editor using ‘Advanced Editor’ option and type the below scripts for validating Phone number
IF( LENGTH($Phone_number) >0 )
length($Phone_number) <24 AND substr($Phone_number, 1, 1) != ‘ ‘ AND
(match_regex($Phone_number, ‘[-/()*# 0-9a-zA-Z ]*’, NULL) ) ;
ELSE RETURN FALSE;
Basically this script checks the below business rules:
1. Phone number should not be blank
2. Length of phone number should be less than 24 characters including Extension
3. Phone number can be alpha numeric value too. (This you can modify based on your business requirements)
Here the Match_Regex function helps you to validate the pattern of a-Z, 0-9 and also some special characters like this -/()*#. The reason why we are allowing these special characters is, in some cases Users may enter the phone number with an extn (E.g.,011688393-extn (889))
Step 3: Now you can test your Rule using Test option and give some test values as shown below.
Step 4: Now you can bind the rule with the Table/view and run the Rule Task to get the Score like below.