Capitallizing with Ucase

I'm trying to create a button to Capitilize the third letter in names that begin with Mc and i can't figure out the syntax ..what am i doing wrong? or is there a better way? I was isolating the variable character with regex then trying to cpaitalize it.

@script vbscript
Option Explicit
Function Rename_GetNewName ( strFileName, strFullPath, fIsFolder, strOldName, ByRef strNewName )

dim re
Set re = new RegExp

re.IgnoreCase = True
re.Global = True
re.Pattern = "(Mc)(.)"
$2 = UCase($2)
strNewName = re.Replace(strNewName, "$1$2")

End Function

Since you're asking several of these questions a week, I'd recommend finding some good VBScript tutorials on the web and spending some time with them.

This kind of thing is very easy to do once you learn the basics of the language, and if you take the time to do that then you'll be able to solve all these problems yourself without having to ask and wait for an answer.

actually i been working on it all day trying to work through examples in the tutorials and i don't understand what i'm doing wrong and i can't find an example from googling or in a tutorial... and thats why i asked

what i pasted above is about 1 of 20 different things i have tried

I think you're trying to run before you can walk. Don't use/skim tutorials just to search for the solution to one problem which you eventually find and then stop reading them. If you do that, every problem you have will require hours/days of searching, copy & pasting code, and trial and error until you stumble on something that appears to work.

Instead, go through some tutorials entirely. Start with ones which explain the fundamentals of the language, not with ones that deal with regexps. (Of course, once you've grasped the fundamentals, VBScript-regexp tutorials will then be useful. But those tutorials will assume you know the basics already and you won't gain as much as you could from them if that isn't true.) Once you get to grips with the fundamentals of the language, using it will be much easier.

Also, it's worth hanging out at a forum for beginner programmers where there are lots of people learning and lots of experienced people who go there specifically to help them. (Unlike here where only a handful of forum members know VBScript and those that do may not have time to answer lots of questions about it.)

Looking at the code in the first post, this line is wrong:

$2 = UCase($2)

$2 isn't a variable. It doesn't mean anything to VBScript, except in the strings you pass to the regexp Replace function. (Even there, $2 still isn't a variable. It's just part of a string which the regexp Replace function uses to work out what to do.)

One way to do what you want is to split the string into parts, the "Mc", the next letter, then everything else. Split each one into a separate variable. Then UCase the one you want to uppercase. Then join them all together.