pattern function

Returns and updates pattern attribute.