I'm trying to replace all instances of the key INPUT_CSV in a string with a file path that is guaranteed to not have any single or double quotes (or other unsafe characters for paths) within it. However, this file path will be surrounded by double quotes.
The key may be surrounded by double quotes, single quotes, or no quotes at all in the input string. I want to be as flexible as possible, and replace all of those instances with the same, double-quoted file path.
This is how I'm currently doing it:
Dim doubleQuotedCsvFilePath As String = """" & generatedCsvFilePath & """"
scriptStr = scriptStr.Replace("""INPUT_CSV""", doubleQuotedCsvFilePath)
scriptStr = scriptStr.Replace("'INPUT_CSV'", doubleQuotedCsvFilePath)
scriptStr = scriptStr.Replace("INPUT_CSV", doubleQuotedCsvFilePath)
Is there some sort of nifty regex (or possibly some other method) that can do essentially this more succinctly? If this is the best way to do it, I'm fine with that too - just wondering if there is a better way. Thanks!
P.S. Not a requirement, but if there was some way to make the regex case-insenstive too (so that e.g. "input_csv", 'input_CSV', or INPut_CSV all get replaced), that would be great also. Thanks!