I have a long string as below. I would like to replace some character when it found some keyword (.abc_ or .ABC_). As the system read line by line, if the keyword is found, then it will replace the word infront to become "john"
insert into material.abc_Inventory; Delete * from table A; ....
insert into job.ABC_Inventory; Show select .....; ....
Changed to
insert into john.ABC_Inventory; Delete * from table A;
insert into john.ABC_Inventory; Show select .....;
Below is my code.
string output = string.Empty;
using (StringReader reader = new StringReader(content))
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.Contains(".ABC_"))
line.Replace(" word in front of the keyword" + line.Substring(line.IndexOf(".ABC_")), " john" + line.Substring(line.IndexOf(".ABC_")));
output += whole line of edited code;
else if (line.Contains(".abc_"))
line.Replace(" word in front of the keyword" + line.Substring(line.IndexOf(".abc_")), " john" + line.Substring(line.IndexOf(".abc_")));
output += whole line of edited code;
else
output += line.ToString();
}
}
I am not able to get the word material or job in front of the keyword.