use regex implementation instead of indexOf
added test case for append('tag.class#id')