Caret behavior fix for empty strings