08-20-2012, 06:59 AM
Hi All,
Please see the program.
The requirement is to Capitelize the first letter of each word in a sentence.
The programmer has used regular expression and getref - to connect to a function which capitelizes the first letter of a given word.
This programs works as expected.
My only question is - where do we pass the arguments to the function 'Capitelize'?? It expects 3 arguments.
Please see the program.
The requirement is to Capitelize the first letter of each word in a sentence.
The programmer has used regular expression and getref - to connect to a function which capitelizes the first letter of a given word.
This programs works as expected.
My only question is - where do we pass the arguments to the function 'Capitelize'?? It expects 3 arguments.
Code:
Dim replacement
Dim regEx : Set regEx = New RegExp ' Create a regular expression.
Dim myString : myString = "Cake, and grief COUNSELING, will be Available at the CoNcLuSiOn of the test."
regEx.Pattern = "\b\w+\b" ' \b = inside word boundary, \w = word character,
' so this pattern matches each single word
regEx.Global = True ' Set the scope to Global
Set replacement = getRef("Capitelize")
Function Capitelize(singleMatch, position, fullString)
Capitelize = ucase(left(singleMatch,1)) & lCase(mid(singleMatch,2))
End Function
MsgBox regEx.Replace(myString, replacement)
' This results in: "Cake, And Grief Counseling, Will Be Available At The Conclusion Of The Test."