There is a problem that has led me to a dead end. I tried to find a good source of information about search, replace, regex, etc. But I can’t compile a ready-made solution from pieces.
The task is this – there is a huge json file in which, among other data, there are records like
"Device", "Input", "Input", "Output", "Output"
related to one device. All values must be searched in double quotes, because they are also found in the file in open form. There are two such devices per floor, 26 floors. I need to rename them with the floor, device number and I/O assignments. For example,
“1 floor Device A”, “1 floor Input A open”, 1 floor Input A close”, “1 floor Input A open”, “1 floor Input A close”.
The same for device B, and so on for each floor.
The biggest problem is composing the replacement string itself – $pattern.replace throws errors whenever I try to substitute counters into it. I think I can dump a pile of cycles myself =)
Used Powershell 2.0 on win7.
Nikollor Maurberg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2