Using Match Regex Function in SAP Information Steward
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
BEGIN
IF( LENGTH($Phone_number) >0 )
BEGIN RETURN
length($Phone_number) <24 AND substr($Phone_number, 1, 1) != ‘ ‘ AND
(match_regex($Phone_number, ‘[-/()*# 0-9a-zA-Z ]*’, NULL) ) ;
END
ELSE RETURN FALSE;
END
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.
Thank you..
Hi Johnpaul, great Blog!
Do you know if is it possible to use the Ascii codes instead of the characters on this function?
Thanks,
Rodrigo.