Replace empty String between the delimiters in java -


i want replace empty space between delimiters "null" . fyi, pipe used delimiter.

for ex : input should

20170703|755636|2ma00012|5|opteqty||||rut|8bndkj4|usd|76.05|-10|-10|-76050|-76050|100|0|100|127|pm

output shoud be:

20170703|755636|2ma00012|5|opteqty|null|null|null|rut|8bndkj4|usd|76.05|-10|-10|-76050|-76050|100|0|100|127|pm

simple use of string.replace function :

      string str = new string("20170703|755636|2ma00012|5|opteqty||||rut|8bndkj4|usd|76.05|-10|-10|-76050|" );        system.out.print("return value :" );       system.out.println(str.replace("||", "|null|")); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -