I'm writing a VBA function to evaluate whether a String is a Valid Full Name or not. For example:
- Válid Full Name:
David Gilmour
Juan Munoz
Claudio Alberto da Silva
- Invalid Full Name:
David Gilm01ur Jr.
Juan Muñoz
Cláudio Alberto da Silva
So the code of my function is this:
Function isVálidoNome(ByVal Texto As String) As Boolean
isVálidoNome = False
'
Dim strPattern As String: strPattern = "(^[a-zA-Z]+(\s?[a-zA-Z])*)*"
'Dim strPattern As String: strPattern = "\d"
Dim regularExpressions As New RegExp
'
regularExpressions.Pattern = strPattern
regularExpressions.Global = True
'
If (regularExpressions.Test(Texto)) Then
isVálidoNome = True
End If
End Function
The pattern I used (^[a-zA-Z]+(\s?[a-zA-Z])*)*
works fine in an app I used to test it (RegexPal), but when I run the code in VBA, Strings with digits, accents returns true
Why this problem or Did I make any mistake?