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.
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
leakim971Connect With a Mentor PluritechnicianCommented:
use : str.replace("'}","}")
test page : http://jsfiddle.net/8fL6z/

or : str.replace(",'}","}")
test page : http://jsfiddle.net/8fL6z/1/
0
 
Tom KnowltonWeb developerAuthor Commented:
This was it, thank you!

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

test page : http://jsfiddle.net/8fL6z/1/
0
 
Tom KnowltonWeb developerAuthor Commented:
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);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.