Le7o,
var str = "tag.class1.class2.class3#id"
function fn(str) {
var tag = "div", match, div = document.createElement("div"), elem;
if (match = str.match(/^[^.#]+/)) {
tag = match[0];
}
elem = document.createElement(tag);
if (match = str.match(/#([^.#]+)/g)) {
elem.id = match[0].slice(1);
}
if (match = str.match(/\.([^.#]+)/g)) {
match.forEach(function(cls) {
elem.classList.add(cls.slice(1));
});
}
div.appendChild(elem);
return div.innerHTML;
};
alert(fn(str))