Use a StringBuilder instead of string concatenation in regex