I’m trying to write a regular expression (via Autohotkey’s RegExReplace function) that will enforce variable casing in exported VBA code as a preprocessing step to version control. So if I want all case-insensitive occurrences of ‘firstName’ to be changed to match that case then the following line:
If FirstName = "" Then MsgBox "Please enter FirstName"
would be translated into:
If firstName = "" Then MsgBox "Please enter FirstName"
If your tool/editor supports look aheads, you could try:
which means:
In plain English: it matches the string ‘FirstName’ (case insensitive) only if it has zero, or an even number of double quotes ahead of it until the end of the line.
Note that it will fail if your line ends with a comment that has a quote in it!