if( keyword1 exists)
then
check if(keyword2 exists in the same line)
then replace keyword 2 with New_Keyword
else
Add New_Keyword at the end of line
end if
eg:
Check for Keyword JUNGLE and add/replace VALUES(TIGER,LION):
Here JUNGLE is Keyword1 and VALUES is Keyword2 and VALUES(TIGER,LION) is New_Keyword.
Lines in INPUT File
JUNGLE Hello WORLD VALUES(DEER,WOLF),
RIVER Hello WORLD,
JUNGLE Hello WORLD,
In Line 1, we can have any values inside ().
Expected OUTPUT File
JUNGLE Hello WORLD VALUES(TIGER,LION),
RIVER Hello WORLD,
JUNGLE Hello WORLD VALUES(TIGER,LION),
In Line 1, we over write the existing values.
In Line 3, we added values at the end.
In Line 2, no changes required and keyword JUNGLE is missing in the line.