Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetRef - Interesting question
#1
Not Solved
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.


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."
Reply


Messages In This Thread
GetRef - Interesting question - by vIns - 08-20-2012, 06:59 AM
RE: GetRef - Interesting question - by Hailesh - 09-21-2019, 12:54 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)