Convert String with Dot or Comma as decimal separator to number in JavaScript
Do a replace first: parseFloat(str.replace(‘,’,’.’).replace(‘ ‘,”))
Do a replace first: parseFloat(str.replace(‘,’,’.’).replace(‘ ‘,”))
Swift 2.0+ Now with Swift 2.0 you can just use Float(Wage.text) which returns a Float? type. More clear than the below solution which just returns 0. If you want a 0 value for an invalid Float for some reason you can use Float(Wage.text) ?? 0 which will return 0 if it is not a valid … Read more
Today (2.5 years after this answer) you can safely use Array.forEach. As @ricosrealm suggests, decodeURIComponent was used in this function. function getJsonFromUrl(url) { if(!url) url = location.search; var query = url.substr(1); var result = {}; query.split(“&”).forEach(function(part) { var item = part.split(“=”); result[item[0]] = decodeURIComponent(item[1]); }); return result; } actually it’s not that simple, see the … Read more
How can I validate an email address using a regular expression?