fixed bug in regex index calculation and added arbitrary limit to key/value pair length