Added custom character mapper and text to pattern function