Tom Knowlton
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.
{ '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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Notes for later:
var datastring = "{ '";
var gather = $('input[gatherkind*="crea tenewuser" ]').each(f unction ()
{
datastring += $(this).attr("customtag") + "' : '" + $(this).val() + "', '";
});
datastring += "}";
var b = datastring.replace(", '}", " }")
alert(b);
var datastring = "{ '";
var gather = $('input[gatherkind*="crea
{
datastring += $(this).attr("customtag") + "' : '" + $(this).val() + "', '";
});
datastring += "}";
var b = datastring.replace(", '}", " }")
alert(b);
ASKER
str.replace(",'}","}")
test page : http://jsfiddle.net/8fL6z/1/