I wish to scan a document for all instances of known numbers. I then wish to replace each occurrence of those numbers with a string. There are 5 different numbers represented in the data and I wish to convert these numbers into a corresponding alphanumeric string.
- Every time a number is found in the data it is preceded by "I/N:" (eg.. I/N:AB1243)
- The numbers are 6 char alphanumeric.(eg AB1243)
- There are 5 different numbers represented (example:A86501, B86502, C86503, A89777 and B89778)
- I want to replace each number with a predetermined string. (eg.. replace all instances of A86501 with Str1, all instances of B86502 with Str2, C86503 with Str3... and so on)
An example input and resultant desired output is as follows:
string Str1= "YELLOW07"
string Str2 = "BLUE82"
string Str3 = "RED31"
Input data:
NM:BLUEMEDIA000001LOC:NewYorkJFKI/N:A86501DT:07082021NM:JUNESWEEPSTAKESLOC:FargoI/N:B86502DT:10/08/2021
Desired output data:
NM:BLUEMEDIA000001LOC:NewYorkJFKI/N:YELLOW07DT:07082021NM:JUNESWEEPSTAKESLOC:FargoI/N:BLUE82DT:10/08/2021