Regular expressions, on their own, do not do stuff, they accept strings. A regex like
[fF][iI][rR][sS][tT][nN][aA][mM][Ee]
will accept the string 'firstname' whatever cases are used. Then you write a replacement operation in your chosen language to replace the string recognised with 'firstName'. You may find that your chosen implementation of regular expressions has a case-insensitive matching capability which would simplify the regex.
The problem you have is in NOT modifying the case of FirstName when it is not in the right position in your expression -- ie how do you change the first occurrence of FirstName in your example, but not the second. In sed it's easy, as by default it only makes replacements the first time a regex is matched in a line. In VBA I haven't a clue.
Is your rule:
- transform case for only the first match;
- transform case only to the left of the first = sign in a string;
- transform case only when match is not inside "";
?
If the third you may have problems if "" can be nested. Regexes can't really cope with arbitrarily-deep nesting of brackets (whatever character is used to bracket), though some implementations have ways around this limitation. However, if you find yourself trying to write a regex to match a string inside a particular number of matching brackets, you can be certain that you are using the wrong tool.
EDIT: in the 3rd case modify my regex to
.*[^"].*[fF][iI][rR][sS][tT][nN][aA][mM][Ee]
which should match any occurrence of firstname not preceded by a "