regex legend spec and refactor legend specs