简体   繁体   中英

How to split string having '|' symbol in java script?

I have string like

var result = 'Zika NAA, Blood|Zika NAA, Urine' 

My requirement is

var result = Zika NAA, Blood

              Zika NAA, Urine

| symbol shouldn't be there and Zika NAA, Urine should come in new line. How to achieve in react js ?

This should work.

  var str = "Zika NAA, Blood|Zika NAA, Urine"; var res = str.split("|").join("\\n"); console.log(res) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM