How to remove character from inside a braces in jquery?

i have data inside a square brackets. i need to remove character in side a braces.

ex:

(a-d){3-5},(A-F){5-8},(0-6){8-9},[#$%^&,+/] 

as above example i need to remove comma(,) inside a square brackets.

i need output as below format.

(a-d){3-5},(A-F){5-8},(0-6){8-9},[#$%^&+/]

how to solve this using jquery or javascript.. ?

Regards Nanda Kishore.CH

Answers 1

  • Could you try to use string.replace, using reg exp like this

    var str = '(a-d){3-5},(A-F){5-8},(0-6){8-9},[#$%^&,+/]';
    str= str.replace(/\,(?![\s\S]*\,)/,"");
    

    Delete last ocurrence of "," in your string expect it helps


Related Articles