regex - replace parenthesis in javascript -


how replace parenthesis javascript.

i have format this:

(14.233,72.456),(12.4566,45.345),(12.456,13.567) 

how can format given below:

14.233,72.456#12.4566,45.345#12.456,13.567 

i have tried following:

bounds = bounds.replace(/\)\,\(/g,'#'); bounds = bounds.replace(/\(/g,''); bounds = bounds.replace(/\)/,''); 

you may try (matches float numbers) :

var s = '(14.233,72.456),(12.4566,45.345),(12.456,13.567)'; bounds = s.match(/\d+\.\d+,\d+\.\d+/g).join('#'); 

s.match(/\d+\.\d+,\d+\.\d+/g) returns :

['14.233,72.456', '12.4566,45.345', '12.456,13.567'] 

in addition, might need deal empty string :

bounds = (s.match(/\d+\.\d+,\d+\.\d+/g) || []).join('#'); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -