Skip to main content

Using a Regular Expression in Validation


Question / Problem: 

Is it possible to create a field type to have a regular expression? Example would be to setup a Social Security # with the dashes: 111-11-1111.

Answer / Solution: 

Currently, the only way to implement a regular expression in Kofax Capture is with a Validation script. 

Here is an example using a regular expression to validate a Social Security number in a Field PostProcessing event:

Private Sub SSNum_FieldPostProcessing(sender As Object, e As PostFieldEventArgs) Handles SSNum.FieldPostProcessing

   If Not Regex.IsMatch(SSNum.IndexField.Value.Trim(), "^(?!000)(?!666)(?!9[0-9][0-9])\d{3}[- ]?(?!00)\d{2}[- ]?(?!0000)\d{4}$") Then
       Throw New ValidationErrorException("Invalid Social Security Number")
   End If

End Sub


Applies to:  

Product Version
Kofax Capture ALL



  • Was this article helpful?