Hi all,
I have a string as follows:
TEST|A||B|C|**""**|D|""|||||\r\n
TEST|Z||V|P|**""**|Y||||||||\r\n
I need to make the content between 5th and 6th occurence of | to blank if the content is "". So the desired output is
TEST|A||B|C||D|""|||||\r\n
TEST|Z||V|P||Y||||||||\r\n
So I am using matcher/pattern and matcher.replaceFirst() using this regex pattern:
String regexPattern = "TEST.*\\|([|\\|]*)\\|([|\\|]*)\\|([|\\|]*)\\|([|\\|]*)\\|\"\"\\|([|\\|]*)"
Though I want only the "" in the 5th and 6th occurence of | to be made EMPTY, the progarm is replacing all "" that it encounters to EMPTY.
So the output is as follows:
TEST|A||B|C||D||||||\r\n
TEST|Z||V|P||Y||||||||\r\n
I am not sure if I need to change the regex pattern that I have? OR is there a way to tell the matcher class to tell that once it changes the first "" do not change other "" in that matched pattern but change it in the other occurence of TEST fragment, If so how?
Any help is appreciated.
Thanks in advance.