This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Basically, if the content between 2nd and 3rd occurance of | is blank and if the content betweeen 5th and 6th occurance of | is "", then make it blank.(Ex: Line 2 in the EXISTING STRING)
Also if the content between 5th and 6th occurrence is not empty and not "" then if the content between 2nd and 3rd occurance of | is blank make it ST.(eX: Line 4,6,7 in existing string)
In other scenarios, nothing needs to be changed.
How to make it possible with Regex replaceall or Pattern/match.
I tried few things but in vain. - str.replaceAll( "(TEST\\\\|[\\|\\|]*\\\\|\\\\|[\\|\\|]*\\\\|[\\|\\|]*\\\\|)\"\"\\|", "$1\\|" ); - I t does not work for 4,6,7 lines/scenarios.