This code uses a lot of "value[4]" - could you extract the parts into useful names then work with them instead? Make it easier then regex changes too...