Refine the replace regexp rule to make it more readable