Counts pattern in buffer or highlighted region