Reputation: 651
Guys if i have string like that:
var tmp1 = "🔑 TakeMe 🔑";
Is this possible (in some easy way) to get text from that variable, but only "TakeMe"? "TakeMe" is beetwen spaces.
var tmp2 = tmp1;
tmp2 == "TakeMe" not "🔑 TakeMe 🔑"
Well guys you know what i mean. Can someone help me with this? My JS skills are really bad ^^
Upvotes: 0
Views: 287
Reputation: 3721
you better use regex
var tmp1 = "🔑 TakeMe 🔑";
var [text] = tmp1.match(/[a-zA-Z]+/g);
console.log(text);
Upvotes: 1
Reputation: 1973
Try this code.
var tmp1 = " TakeMe ";
var tmp2 = tmp1.trim();
console.log(tmp2);
Upvotes: 0