• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 135
  • Last Modified:

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.
0
Tom Knowlton
Asked:
Tom Knowlton
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now