Jeffrey Lebowski
Member
Hi all,
I have been picking apart an Excel file with a lot of code in it, in an attempt to recreate the file and understand the vba behind it. It seems the public functions are all being initialized with the same structure, declaring a variable as a "RegExp" which I believe stands for regular expression, but the content I have found in my research has left me very confused. Can someone explain to me (or point me in the right direction) what RegExp does and if there is a better way to rewrite the following code?
Thanks!
>>The function below is used to check whether a field is alphanumeric or not using regular expression
>>If format matches then returns true else returns false
I have been picking apart an Excel file with a lot of code in it, in an attempt to recreate the file and understand the vba behind it. It seems the public functions are all being initialized with the same structure, declaring a variable as a "RegExp" which I believe stands for regular expression, but the content I have found in my research has left me very confused. Can someone explain to me (or point me in the right direction) what RegExp does and if there is a better way to rewrite the following code?
Thanks!
>>The function below is used to check whether a field is alphanumeric or not using regular expression
>>If format matches then returns true else returns false
Code:
Public Function CheckAlphaNumericPart1(inputData As String) As Boolean
Dim objRegExp As RegExp
Dim blnValid As Boolean
Set objRegExp = New RegExp
With objRegExp
.Pattern = "^[0-9]+[a-zA-Z]+[a-zA-Z0-9]*$"
.IgnoreCase = True
.Global = True
End With
blnValid = objRegExp.test(inputData)
Set objRegExp = Nothing
CheckAlphaNumericPart1 = blnValid
End Function