Function: IsPatternMatch
The function IsPatternMatch is a new functionality in TallyPrime Release 6.0 that will allow the user to check any input string against a regular expression pattern. Before we discuss how this function works, let’s understand what a regular expression is.
Regular Expression
A regular expression (often known as regex) is a sequence of characters that is used to define a search pattern for strings. It is primarily used to find specific patterns in text, such as validating input, searching, or manipulating strings.
In this new capability, IsPatternMatch, this function will help in pattern-based validations and similar functionality.
$$IsPatternMatch
This function will check whether the given input string matches the specified pattern (regular expression pattern). It will take two parameters, Parameter 1 → Input String and Parameter 2 → Regular Expression (Regex) Pattern. This can be used to validate various and match string patterns like GST format, E-mail, Aadhar number, PAN number, etc.
Syntax
Format Name: $$IsPatternMatch: (Parameter 1): Parameter 2
Here, Format Name is the name that needs to be validated.
$$IsPatternMatch → Function which will check for the string match with the pattern.
Parameter 1 → Input String to be validated (Mandatory).
Parameter 2 → Regular expression (Mandatory).
In some case, Parameter 3 can also be used when you want to match regular express with text in a case insensitive manner or not. By default, the value for this parameter is FALSE.
Example
[Line: TSPL IPM StrInput]
Space Top: 1.0
Field : Medium Prompt, TSPL IPM String Input, TSPL IPM Reg Expression
Local : Field : MediumPrompt : Set as : “Email ID”
Local : Field : MediumPrompt : Indent : 4
[Field: TSPL IPM String Input]
Use : Name Field
On : Accept : ($$IsPatternMatch:#TSPLIPMStringInput:#TSPLIPMRegExpression): Call:
On : Accept : Not($$IsPatternMatch:#TSPLIPMStringInput:#TSPLIPMRegExpression):Call: TSPL IPM Msg Box
Case : Lower Case
[Field: TSPL IPM Reg Expression]
Use : Name Field
Set as : “^([a-zA-Z0-9._%-]+@[gmailGMAIL]+\.[a-zA-Z]{3})$”
Skip : Yes
Full Width : Yes
Invisible : Yes
Here, #TSPLIPMStringInput → Function which will take the input string
#TSPLIPMRegExpression → Function which will hold the regular expression to me matched with
TSPLIPMDisplayReport → Function defined which will display the report if the pattern matches
TSPL IPM Msg Box → Function defined which will display the error if the pattern doesn’t match