• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
        • compare Function
        • compareNoCase Function
        • Concat Function
        • String Concatenation Operator
        • Edit Function
        • GetBuffer Function
        • Length Function
        • maketext Function
        • Message Formatting Options
        • Pos Function
        • PosChar Function
        • RegExMatch Function
        • Replace Function
        • StartsWith Function
        • Strip Function
        • ToLower Function
        • ToNumber Function
        • ToUpper Function
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

RegExMatch Function

Format
i = regexmatch(target_string, regex_string);
Description
The regexmatch function tests whether the target_string matches the regex_string.
Return Value
The function returns an integer value of:
1if target_string matches regex_string.
0if target_string does not match regex_string.
Writing and Testing Regular Expressions
Regular expressions have their own syntax separate from CSPro logic. Therefore, it is recommended to write and test your regular expressions in a regular expression editor. Use any regular expression editor that supports ECMAScript (JavaScript) engine (or flavor). One such editor is regex101, just make sure you change the flavor to ECMAScript.
Example
// Matches format xxx-xxx-xxxx
if regexmatch(TELEPHONE_NUMBER, "^([0-9]{3}-){2}[0-9]{4}$") then
   
// ...
endif;

// Basic validation for email
if regexmatch(EMAIL, @"^[^@\s]+@[^@\s]+\.[^@\s]+$") then
   
// ...
endif;