Link to home
Start Free TrialLog in
Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America

asked on

remove chars from end of string

I want to change this:

{ 'firstname' : 'bob', 'lastname' : 'smith', 'address1' : 'abc ave.', '}

to this:

{ 'firstname' : 'bob', 'lastname' : 'smith', 'address1' : 'abc ave.' }   //////////    , '     (the comma and the single quote) before the  ending }    have been removed.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tom Knowlton

ASKER

This was it, thank you!

str.replace(",'}","}")

test page : http://jsfiddle.net/8fL6z/1/
Notes for later:

 var datastring = "{ '";

            var gather = $('input[gatherkind*="createnewuser"]').each(function ()
            {
                datastring += $(this).attr("customtag") + "' : '" + $(this).val() + "', '";  
            });

            datastring += "}";

            var b = datastring.replace(", '}", " }")


            alert(b);