Environment: Win XP
Access 2000
Microsoft VBScript Regular Expressions 5.5
I'm teaching myself regular expressions, so I'm starting slow. I want to test for the presence of a defined number of occurrences of a particular character. For example, if the string were "Mary had a little lamb," I might test for exactly 4 'a' characters. My understanding of VB's implementation of regex is that the following pattern ought to evaluate to true when tested:
Unfortunately, it does not.
Here is my actual code, and the output it produces:
As you can see from the output, the test string has 3 'h' chars in it, yet the count shows 0. Any idea where I'm going wrong?
TIA
"There is no spoon..." - anonymous enlightened child
Access 2000
Microsoft VBScript Regular Expressions 5.5
I'm teaching myself regular expressions, so I'm starting slow. I want to test for the presence of a defined number of occurrences of a particular character. For example, if the string were "Mary had a little lamb," I might test for exactly 4 'a' characters. My understanding of VB's implementation of regex is that the following pattern ought to evaluate to true when tested:
Code:
regexobj.Pattern = "a{4}"
Here is my actual code, and the output it produces:
Code:
Public Sub SeeHand()
'Test sub to get hand data and sort it
Dim rs As DAO.Recordset
Dim rsq As DAO.QueryDef
Dim rgxp As New RegExp
Dim strBoardandHoleCards As String
Set rsq = CurrentDb().QueryDefs("qrySeeShowdownCards")
Set rs = rsq.OpenRecordset
strBoardandHoleCards = rs.Fields("HandStr")
rgxp.Global = True
rgxp.IgnoreCase = True
rgxp.Pattern = "h{3}"
Debug.Print strBoardandHoleCards
Set rest = rgxp.Execute(strBoardandHoleCards)
Debug.Print rest.Count
End Sub
Output (from the immediate window): 2c9sAhTsTh7h 3s
0
As you can see from the output, the test string has 3 'h' chars in it, yet the count shows 0. Any idea where I'm going wrong?
TIA
"There is no spoon..." - anonymous enlightened child