Reputation: 143
In a variable I have a string value Agriculture & Development. I want to remove Whitespaces and character '&' from the string Agriculture & Development so that it looks like Agriculture_Development using jquery or javascript.
Upvotes: 0
Views: 163
Reputation: 122906
No need for jquery here, plain js will do:
var nwstr = 'Agriculture & Development'
.replace(/\s+/g,'')
.replace(/\&/,'_');
//=> Agriculture_Development
Now go and figure things out yourself
Upvotes: 4
Reputation: 1643
var str = "Agriculture & Development";
// replace all the white space and the &
str.replace(/\s+/g, '').replace(/\&/,'_');
Upvotes: 1