You must Sign In to post a response.
  • Category: JQuery

    How to remove character from inside a braces in jquery ?

    Hi team,
    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
  • #765411
    It can be done as :

    var a=' (a-d){3-5},(A-F){5-8},(0-6){8-9},[#$%^&,+/] ';
    var index=a.indexOf('[');
    var x=a.substring(0,index);
    var y=a.substring(index,a.length);

    var output=x.concat(y.replace(',',''));

    Thanks!
    Anjali Bansal

    ~Give your best and lead the world

  • #765486
    Use str.replace method.

    var s = '(a-d){3-5},(A-F){5-8},(0-6){8-9},[#$%^&,+/]';
    alert(s.replace(/\[[^\]]*\]/g, function(x){return x.replace(/,/g, '')}))


  • Sign In to post your comments