I have a string of data with line breaks in the middle. For instance:
"Product Name \n Product Color \n Product Quantity \n Product Location \n Product Size \n Product Power"
The number of elements in the string could be endless.
I am looking to substitute the \n
with >>>> \n
, but only when the line numbers exceed 3 and not on the last line. The last line should display (end)
.
I've attempted using map, splitting and replacing. However, I am struggling to loop through the array to pinpoint the lines that need modification, as well as rejoining them after all lines are updated.
The input is:
"Retract-A-Banner\n**Template:\nFull Color\nImprint Information:\nCL: 488 Special Ops Wing\n353 SOW Integrated Resilience Optimization Network\n"
Expected Output:
"Retract-A-Banner\n**Template:\nFull Color >>>>\nImprint Information: >>>>\nCL: 488 Special Ops Wing >>>>\n353 SOW Integrated Resilience Optimization Network(end)\n"