regex fixes (determin type)

doc-buffer function extracted