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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -