javascript - How to separate comma in js -


my input string below:

in|1st cross,1st block,in|282,sector 19,in|10th floor,winchester house,dn|id,fgh,fg|ag 

what want should like:

in|1st cross,1st block in|282,sector 19 in|10th floor,winchester house dn|id,fgh fg|ag 

please how achieve above result?

there go:

function separatecomaforcountry(str) {     // find coma, has amount of letters after not , nor | , stop when see either end of string or |      var reg = /,([^|,]+(?:$|\|))/g;     return str.replace(reg, function(match, country){         return ' ' + country;     }); } 

then call function use case.

separatecomaforcountry("in|1st cross,1st block,in|282,sector 19,in|10th floor,winchester house,dn|id,fgh,fg|ag"); // outputs in|1st cross,1st block in|282,sector 19 in|10th floor,winchester house dn|id,fgh fg|ag 

Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -