Hi,
I have a problem using regular expressions, in which I don't find the correct pattern to return the right values.
I have a table, in which in the records, names are stored. For example:
Street Alex
Victorian Runway
etc.
The goal is to check whether the user has filled in the names using a "mixed case" rule: so each word has to start with a capital and followed by small letters.
My code works on the opposite: it looks were there is a word starting with a little case and if so, it returns "False" else, it is true:
However, this works but following values are also returned as false:
D'soui Street
S'vanaah Kai
So when there is an apostrophe is it seen as wrong, while these names are right.
How can I change the pattern to overcome this problem?
Thanks for any help!
Leen
I have a problem using regular expressions, in which I don't find the correct pattern to return the right values.
I have a table, in which in the records, names are stored. For example:
Street Alex
Victorian Runway
etc.
The goal is to check whether the user has filled in the names using a "mixed case" rule: so each word has to start with a capital and followed by small letters.
My code works on the opposite: it looks were there is a word starting with a little case and if so, it returns "False" else, it is true:
Code:
Function regexpCase(astring As String) As String 'use mixed cases via regular expressions
Dim regEx As Object
Set regEx = CreateObject("vbscript.regexp")
With regEx
.Pattern = "(\b[a-z][a-z]*\b)" 'not a mixed case
.Ignorecase = False
.Global = False
End With
Set matches = regEx.Execute(astring)
If matches.Count = 0 Then
regexpCase = astring 'no error, then none of the strings start with a lower Case
Else
regexpCase = vbNullString 'error, one of the strings does not start with a lower Case
End If
Set matches = Nothing
Set regEx = Nothing
End Function
However, this works but following values are also returned as false:
D'soui Street
S'vanaah Kai
So when there is an apostrophe is it seen as wrong, while these names are right.
How can I change the pattern to overcome this problem?
Thanks for any help!
Leen