REGEX or Regular Expression in Salesforce
REGEX(Input_Field_Name, 'Input_Format_Expression')
i.e. BLKPR7234B or blkpr7234b:
NOT REGEX( PAN_Number__c , '[A-Z,a-z]{5}[0-9]{4}[A-Z,a-z]{1}' )
REGEX(Input_Field_Name, 'Input_Format_Expression')
i.e. BLKPR7234B or blkpr7234b:
NOT REGEX( PAN_Number__c , '[A-Z,a-z]{5}[0-9]{4}[A-Z,a-z]{1}' )
This function is Boolean, which is used to compare text format between the input text and the specified expression. If both the text format and expression are equal, then it returns true, else it returns false.
Prepare the regular expression by using wild-card characters as below.
[ ] --> Indicates a collection of characters
[A-Z] --> Indicates a collection of characters falls
between A-Z.
[a-z] --> Indicates a collection of characters falls
between a-z.
[A-Z,a-z] --> Indicates a collection of characters falls
between A-Z or a-z or combination of both.
[0-9] --> Indicates a Number, where each digit should be
falls between 0-9.
{Number} --> Indicates the Number of characters should be
used in the string.
[JKL] --> Indicates a collection of characters, where
each characters should be either J/K/L.
- --> Represents a Single Character.
PAN Number Format: BLKPR 7234 J
BLKPR --> 5
7234 --> 4
J --> 1
BLKPR7234J:
Format: [A-Z]{5}[0-9]{4}[A-Z]{1}
bLkPr7234j:
Format: [A-Z,a-z]{5}[0-9]{4}[A-Z,a-z]{1}
//Create a validation rule, to validate the PAN Number format.
Validation Condition:
i.e. BLKPR7234B or blkpr7234b:
NOT REGEX( PAN_Number__c , '[A-Z,a-z]{5}[0-9]{4}[A-Z,a-z]{1}' )
Prepare the regular expression by using wild-card characters as below.
[ ] --> Indicates a collection of characters
[A-Z] --> Indicates a collection of characters falls
between A-Z.
[a-z] --> Indicates a collection of characters falls
between a-z.
[A-Z,a-z] --> Indicates a collection of characters falls
between A-Z or a-z or combination of both.
[0-9] --> Indicates a Number, where each digit should be
falls between 0-9.
{Number} --> Indicates the Number of characters should be
used in the string.
[JKL] --> Indicates a collection of characters, where
each characters should be either J/K/L.
- --> Represents a Single Character.
PAN Number Format: BLKPR 7234 J
BLKPR --> 5
7234 --> 4
J --> 1
BLKPR7234J:
Format: [A-Z]{5}[0-9]{4}[A-Z]{1}
bLkPr7234j:
Format: [A-Z,a-z]{5}[0-9]{4}[A-Z,a-z]{1}
//Create a validation rule, to validate the PAN Number format.
Validation Condition:
i.e. BLKPR7234B or blkpr7234b:
NOT REGEX( PAN_Number__c , '[A-Z,a-z]{5}[0-9]{4}[A-Z,a-z]{1}' )
No comments:
Post a Comment